From bba80bc80f5408af9ab8a3708d44712b8df4d701 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Fri, 3 May 2019 08:23:11 -0500 Subject: [PATCH] Fix content-type for HEAD '.jpg' --- src/invidious.cr | 2 +- src/invidious/helpers/handlers.cr | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/invidious.cr b/src/invidious.cr index 1399c124..1603f4e6 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -5168,7 +5168,7 @@ get "/sb/:id/:storyboard/:index" do |env| env.response.headers[key] = value end - if response.status_code == 304 + if response.status_code >= 400 break end diff --git a/src/invidious/helpers/handlers.cr b/src/invidious/helpers/handlers.cr index 560ed670..98087ec7 100644 --- a/src/invidious/helpers/handlers.cr +++ b/src/invidious/helpers/handlers.cr @@ -33,6 +33,11 @@ class Kemal::RouteHandler raise Kemal::Exceptions::CustomException.new(context) end + if context.request.method == "HEAD" && + context.request.path.ends_with? ".jpg" + context.response.headers["Content-Type"] = "image/jpeg" + end + context.response.print(content) context end