Support Crystal 0.35.0

This commit is contained in:
Omar Roth
2020-06-15 17:57:20 -05:00
parent 338dc3223c
commit d30a972a90
6 changed files with 48 additions and 22 deletions

View File

@@ -81,12 +81,12 @@ def send_file(env : HTTP::Server::Context, file_path : String, data : Slice(UInt
condition = config.is_a?(Hash) && config["gzip"]? == true && filesize > minsize && Kemal::Utils.zip_types(file_path)
if condition && request_headers.includes_word?("Accept-Encoding", "gzip")
env.response.headers["Content-Encoding"] = "gzip"
Gzip::Writer.open(env.response) do |deflate|
Compress::Gzip::Writer.open(env.response) do |deflate|
IO.copy(file, deflate)
end
elsif condition && request_headers.includes_word?("Accept-Encoding", "deflate")
env.response.headers["Content-Encoding"] = "deflate"
Flate::Writer.open(env.response) do |deflate|
Compress::Deflate::Writer.open(env.response) do |deflate|
IO.copy(file, deflate)
end
else