From 8d0875f64c4e2d227cdf71b4edb5ef4079154325 Mon Sep 17 00:00:00 2001 From: jinn999 Date: Sun, 7 Mar 2021 12:29:49 +0100 Subject: [PATCH] Fix StaticFileHandler failing spec (#599) --- spec/static_file_handler_spec.cr | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/static_file_handler_spec.cr b/spec/static_file_handler_spec.cr index 1aac161..e9307f6 100644 --- a/spec/static_file_handler_spec.cr +++ b/spec/static_file_handler_spec.cr @@ -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