From 83ba4e2a4c1cb974d20499867b0fd445071ea07e Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Mon, 17 Sep 2018 14:48:02 -0500 Subject: [PATCH] Fix truncated thumbnails --- src/invidious.cr | 9 ++++----- src/invidious/helpers/helpers.cr | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 5c809eab..38c3e018 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -3011,7 +3011,6 @@ get "/vi/:id/:name" do |env| client.get(url, headers) do |response| env.response.status_code = response.status_code - puts response.headers.inspect response.headers.each do |key, value| env.response.headers[key] = value end @@ -3021,23 +3020,23 @@ get "/vi/:id/:name" do |env| end chunk_size = 4096 - size = chunk_size + size = 1 if response.headers.includes_word?("Content-Encoding", "gzip") Gzip::Writer.open(env.response) do |deflate| - until size < chunk_size + until size == 0 size = IO.copy(response.body_io, deflate) env.response.flush end end elsif response.headers.includes_word?("Content-Encoding", "deflate") Flate::Writer.open(env.response) do |deflate| - until size < chunk_size + until size == 0 size = IO.copy(response.body_io, deflate) env.response.flush end end else - until size < chunk_size + until size == 0 size = IO.copy(response.body_io, env.response, chunk_size) env.response.flush end diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index fccffd18..68c5cc5b 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -18,7 +18,7 @@ class Config end class FilteredCompressHandler < Kemal::Handler - exclude ["/videoplayback", "/videoplayback/*", "/api/*"] + exclude ["/videoplayback", "/videoplayback/*", "/vi/*", "/api/*"] def call(env) return call_next env if exclude_match? env