Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compress handler returns empty body for HTTP server #4064

Closed
ukd1 opened this issue Feb 23, 2017 · 1 comment
Closed

Compress handler returns empty body for HTTP server #4064

ukd1 opened this issue Feb 23, 2017 · 1 comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib
Milestone

Comments

@ukd1
Copy link

ukd1 commented Feb 23, 2017

Possibly related to #4060, @ezrast and I found when hacking -when using the compress handler, the response has no body when using curl or browsers; removing the accept encoding headers, things work as expected.

$ crystal -v
Crystal 0.21.0 (2017-02-21)

Code:

require "http/server"
require "http/server/handlers/compress_handler"

server = HTTP::Server.new("localhost", 3000, [HTTP::CompressHandler.new]
) do |context|
  context.response.status_code = 200
  context.response << %{
<html><body>
<p>HAI: #{context.request.path}.
</body></html>
}
end

puts "Launching server at http://localhost:3000"
puts "Press Ctrl+C to exit"
server.listen

Bug:

$ curl --compressed -vv http://localhost:3000/
*   Trying ::1...
* Connected to localhost (::1) port 3000 (#0)
> GET / HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.49.1
> Accept: */*
> Accept-Encoding: deflate, gzip
> 
< HTTP/1.1 200 OK
< Connection: keep-alive
< Content-Encoding: gzip
< Content-Length: 54
< 
* Connection #0 to host localhost left intact

without compression things work as expected:

$ curl -vv http://localhost:3000/
*   Trying ::1...
* Connected to localhost (::1) port 3000 (#0)
> GET / HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.49.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< Connection: keep-alive
< Content-Length: 40
< 

<html><body>
<p>HAI: /.
</body></html>
* Connection #0 to host localhost left intact
@ukd1 ukd1 mentioned this issue Feb 23, 2017
@spalladino spalladino added the kind:bug A bug in the code. Does not apply to documentation, specs, etc. label Feb 27, 2017
@asterite asterite added this to the Next milestone Mar 1, 2017
@asterite
Copy link
Member

asterite commented Mar 1, 2017

Fixed by #4068

@asterite asterite closed this as completed Mar 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib
Projects
None yet
Development

No branches or pull requests

3 participants