mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
Add filtered handler for videoplayback
This commit is contained in:
parent
f08199e7cf
commit
bc068721ab
2 changed files with 26 additions and 1 deletions
|
@ -29,6 +29,30 @@ class Config
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class FilteredCompressHandler < Kemal::Handler
|
||||||
|
exclude ["/videoplayback"]
|
||||||
|
|
||||||
|
def call(env)
|
||||||
|
return call_next env if exclude_match? env
|
||||||
|
|
||||||
|
{% if flag?(:without_zlib) %}
|
||||||
|
call_next env
|
||||||
|
{% else %}
|
||||||
|
request_headers = env.request.headers
|
||||||
|
|
||||||
|
if request_headers.includes_word?("Accept-Encoding", "gzip")
|
||||||
|
env.response.headers["Content-Encoding"] = "gzip"
|
||||||
|
env.response.output = Gzip::Writer.new(env.response.output, sync_close: true)
|
||||||
|
elsif request_headers.includes_word?("Accept-Encoding", "deflate")
|
||||||
|
env.response.headers["Content-Encoding"] = "deflate"
|
||||||
|
env.response.output = Flate::Writer.new(env.response.output, sync_close: true)
|
||||||
|
end
|
||||||
|
|
||||||
|
call_next env
|
||||||
|
{% end %}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class Video
|
class Video
|
||||||
module HTTPParamConverter
|
module HTTPParamConverter
|
||||||
def self.from_rs(rs)
|
def self.from_rs(rs)
|
||||||
|
|
|
@ -872,6 +872,7 @@ static_headers do |response, filepath, filestat|
|
||||||
end
|
end
|
||||||
|
|
||||||
public_folder "assets"
|
public_folder "assets"
|
||||||
gzip true
|
|
||||||
|
add_handler FilteredCompressHandler.new
|
||||||
|
|
||||||
Kemal.run
|
Kemal.run
|
||||||
|
|
Loading…
Reference in a new issue