Skip to content

Server crashes when using gzip compression #32

Open
@floriandejonckheere

Description

@floriandejonckheere

Tipi's Rack adapter crashes when a request with Accept-Encoding: gzip is handled:

/usr/local/bundle/gems/tipi-0.55/lib/tipi/rack_adapter.rb:28:in `respond': undefined method `first' for #<Rack::Deflater::GzipStream:0x00007f6c78931930 @body=#<Rack::BodyProxy:0x00007f6c78932a10 @body=["Not Found\n"], @block=#<Proc:0x00007f6c78932920 /usr/local/bundle/gems/rack-3.0.8/lib/rack/common_logger.rb:45>, @closed=false>, @mtime=nil, @sync=true> (NoMethodError)

            body.first
                ^^^^^^
	from /usr/local/bundle/gems/tipi-0.55/lib/tipi/rack_adapter.rb:9:in `block in run'
	from /usr/local/bundle/gems/tipi-0.55/lib/tipi/http1_adapter.rb:52:in `handle_request'
	from /usr/local/bundle/gems/tipi-0.55/lib/tipi/http1_adapter.rb:28:in `each'
	from /usr/local/bundle/gems/tipi-0.55/lib/tipi.rb:50:in `client_loop'
	from /usr/local/bundle/gems/tipi-0.55/lib/tipi.rb:41:in `block (2 levels) in accept_loop'
/srv # bundle exec ruby tipi.rb
Starting metrics server on 0.0.0.0:9394
/usr/local/bundle/gems/tipi-0.55/lib/tipi/rack_adapter.rb:28:in `respond': undefined method `first' for #<Rack::Deflater::GzipStream:0x00007fc887ff7768 @body=#<Rack::BodyProxy:0x00007fc887ff7cb8 @body=["Not Found\n"], @block=#<Proc:0x00007fc887ff7c68 /usr/local/bundle/gems/rack-3.0.8/lib/rack/common_logger.rb:45>, @closed=false>, @mtime=nil, @sync=true> (NoMethodError)

The code I was using at the moment:

require "tipi"
require "yabeda"
require "yabeda/prometheus"

Tipi.serve(
  "0.0.0.0",
  9394,
  { reuse_addr: true, dont_linger: true },
  &Tipi::RackAdapter.run(Yabeda::Prometheus::Exporter.rack_app)
)

The request that triggers the crash:

curl -sH 'Accept-Encoding: gzip' localhost:9394

The problem seems to be that Tipi::RackAdapter receives the Rack::BodyProxy object wrapped in a Rack::Deflater::GzipStream when compression is requested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions