diff options
| author | Samantaz Fox <coding@samantaz.fr> | 2021-11-16 21:40:35 +0100 |
|---|---|---|
| committer | Samantaz Fox <coding@samantaz.fr> | 2021-11-16 21:40:35 +0100 |
| commit | 2c447a42f29a05b8067444338248e344b3705cd0 (patch) | |
| tree | d894f9eda140ac0b8e5c664639e940ef305d9e3e | |
| parent | dad8f9a0ce576ce3e938fbaa578d12179ca63553 (diff) | |
| download | invidious-2c447a42f29a05b8067444338248e344b3705cd0.tar.gz invidious-2c447a42f29a05b8067444338248e344b3705cd0.tar.bz2 invidious-2c447a42f29a05b8067444338248e344b3705cd0.zip | |
Make sure to only apply fix if QUIC is disabled
| -rw-r--r-- | src/invidious/yt_backend/youtube_api.cr | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/invidious/yt_backend/youtube_api.cr b/src/invidious/yt_backend/youtube_api.cr index 4973e4de..b26af8d1 100644 --- a/src/invidious/yt_backend/youtube_api.cr +++ b/src/invidious/yt_backend/youtube_api.cr @@ -425,19 +425,23 @@ module YoutubeAPI ) end - # Decompress the body ourselves, given that auto-decompress is - # broken in the Crystal stdlib. - # Read more: - # - https://github.com/iv-org/invidious/issues/2612 - # - https://github.com/crystal-lang/crystal/issues/11354 - # - case response.headers["Content-Encoding"]? - when "gzip" - body = Compress::Gzip::Reader.new(response.body_io, sync_close: true) - when "deflate" - body = Compress::Deflate::Reader.new(response.body_io, sync_close: true) - else + if {{ !flag?(:disable_quic) }} && CONFIG.use_quic body = response.body + else + # Decompress the body ourselves, when using HTTP::Client given that + # auto-decompress is broken in the Crystal stdlib. + # Read more: + # - https://github.com/iv-org/invidious/issues/2612 + # - https://github.com/crystal-lang/crystal/issues/11354 + # + case response.headers["Content-Encoding"]? + when "gzip" + body = Compress::Gzip::Reader.new(response.body_io, sync_close: true) + when "deflate" + body = Compress::Deflate::Reader.new(response.body_io, sync_close: true) + else + body = response.body + end end # Convert result to Hash |
