From: Samuel Williams <samuel@oriontransfer.net>
To: Eric Wong <e@yhbt.net>, unicorn-public@yhbt.net
Subject: Re: Is Rack partial hijack supported?
Date: Mon, 29 Aug 2022 19:19:48 +1200 [thread overview]
Message-ID: <75F28F52-26B6-4BBE-B6A0-AD4F6D8855CD@oriontransfer.net> (raw)
In-Reply-To: <20220829064245.GA1272@dcvr>
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
next prev parent reply other threads:[~2022-08-29 7:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-29 5:56 Is Rack partial hijack supported? Samuel Williams
2022-08-29 6:42 ` Eric Wong
2022-08-29 7:19 ` Samuel Williams [this message]
2022-08-29 8:14 ` Eric Wong
2022-09-01 21:53 ` Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/unicorn/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=75F28F52-26B6-4BBE-B6A0-AD4F6D8855CD@oriontransfer.net \
--to=samuel@oriontransfer.net \
--cc=e@yhbt.net \
--cc=unicorn-public@yhbt.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/unicorn.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).