mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Fix StaticFileHandler failing spec (#599)
This commit is contained in:
parent
f71a83e2c4
commit
8d0875f64c
1 changed files with 5 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
|||
require "./spec_helper"
|
||||
|
||||
private def handle(request, fallthrough = true)
|
||||
private def handle(request, fallthrough = true, decompress = true)
|
||||
io = IO::Memory.new
|
||||
response = HTTP::Server::Response.new(io)
|
||||
context = HTTP::Server::Context.new(request, response)
|
||||
|
@ -8,7 +8,7 @@ private def handle(request, fallthrough = true)
|
|||
handler.call context
|
||||
response.close
|
||||
io.rewind
|
||||
HTTP::Client::Response.from_io(io)
|
||||
HTTP::Client::Response.from_io(io, decompress: decompress)
|
||||
end
|
||||
|
||||
describe Kemal::StaticFileHandler do
|
||||
|
@ -51,7 +51,7 @@ describe Kemal::StaticFileHandler do
|
|||
it "should gzip a file if config is true, headers accept gzip and file is > 880 bytes" do
|
||||
serve_static({"gzip" => true, "dir_listing" => true})
|
||||
headers = HTTP::Headers{"Accept-Encoding" => "gzip, deflate, sdch, br"}
|
||||
response = handle HTTP::Request.new("GET", "/dir/bigger.txt", headers)
|
||||
response = handle HTTP::Request.new("GET", "/dir/bigger.txt", headers), decompress: false
|
||||
response.status_code.should eq(200)
|
||||
response.headers["Content-Encoding"].should eq "gzip"
|
||||
end
|
||||
|
@ -59,7 +59,7 @@ describe Kemal::StaticFileHandler do
|
|||
it "should not gzip a file if config is true, headers accept gzip and file is < 880 bytes" do
|
||||
serve_static({"gzip" => true, "dir_listing" => true})
|
||||
headers = HTTP::Headers{"Accept-Encoding" => "gzip, deflate, sdch, br"}
|
||||
response = handle HTTP::Request.new("GET", "/dir/test.txt", headers)
|
||||
response = handle HTTP::Request.new("GET", "/dir/test.txt", headers), decompress: false
|
||||
response.status_code.should eq(200)
|
||||
response.headers["Content-Encoding"]?.should be_nil
|
||||
end
|
||||
|
@ -67,7 +67,7 @@ describe Kemal::StaticFileHandler do
|
|||
it "should not gzip a file if config is false, headers accept gzip and file is > 880 bytes" do
|
||||
serve_static({"gzip" => false, "dir_listing" => true})
|
||||
headers = HTTP::Headers{"Accept-Encoding" => "gzip, deflate, sdch, br"}
|
||||
response = handle HTTP::Request.new("GET", "/dir/bigger.txt", headers)
|
||||
response = handle HTTP::Request.new("GET", "/dir/bigger.txt", headers), decompress: false
|
||||
response.status_code.should eq(200)
|
||||
response.headers["Content-Encoding"]?.should be_nil
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue