Thanks Eric.

> # This works fine:
> $ unicorn -E none hijack.ru
> $ curl -Ssf http://0:8080/
> 
> # This fails since Rack::Chunk is loaded by default:
> $ unicorn hijack.ru
> $ curl -Ssf http://0:8080/
> curl: (56) Illegal or missing hexadecimal sequence in chunked-encoding
> 
> So I think the hijack callback needs to do the chunking itself;
> I'm not sure...
> 
> That said, I have no idea if rack.hijack gets used at all w/
> unicorn; and I seem to recall there being a bit of confusion
> on how hijack and middleware would interact…

Using `-E none` solves the issue and I can proceed with the conformance checks, 
thanks! AFAIK, no other server behaves like this (using `Rack::Server` for 
default middleware) although I can understand why for Rack 2 that was a logical 
choice.

FYI, we have deprecated `Rack::Chunked` in Rack 3. The wire format should be 
the responsibility of the server, not the application/middleware. This 
middleware in particular was a blocker to support HTTP/2 which does chunked 
encoding using binary framing. In addition, `Rack::Server` has also been moved 
out of the Rack gem. The Rack gem should focus on Rack the interface, rather 
than Rack the (server) implementation. As such, the 
`default_middleware_by_environment` should be an internal detail of the 
implementation rather than the middleware/application.

My suggestion is that you implement chunked encoding directly in your server 
and only if it makes sense according to the response you get back from the 
application. For a hijacked response, given that you are already using 
`connection: close`, you can probably just directly pass the socket to the 
hijack proc. This will be compatible with websockets too.

Kind regards,
Samuel--
unsubscribe: one-click, see List-Unsubscribe header
archive: https://yhbt.net/unicorn-public/

Reply via email to