From: Eric Wong <e@80x24.org> To: yahns-public@yhbt.net Subject: [PUSHED] http_response: support rack.hijack on HTTP/0.9 responses Date: Tue, 29 Nov 2016 21:05:16 +0000 [thread overview] Message-ID: <20161129210516.GA11386@starla> (raw) We still need to iterate through all response headers to support response-only Rack hijacking. Previously, we only supported full hijacking on so-called "HTTP/0.9" clients. n.b. This diff will be easier to read with the -b/--ignore-space-change option of git-diff(1) or GNU diff(1) --- lib/yahns/http_response.rb | 114 ++++++++++++++++++++++----------------------- test/test_rack_hijack.rb | 6 +++ 2 files changed, 62 insertions(+), 58 deletions(-) diff -b --git a/lib/yahns/http_response.rb b/lib/yahns/http_response.rb index e2fc940..a31ab70 100644 --- a/lib/yahns/http_response.rb +++ b/lib/yahns/http_response.rb @@ -131,7 +131,6 @@ def http_response_write(res, opt) term = false hdr_only, chunk_ok = opt - if @hs.headers? code = status.to_i hdr_only ||= Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include?(code) msg = Rack::Utils::HTTP_STATUS_CODES[code] @@ -191,8 +190,7 @@ def http_response_write(res, opt) else response_wait_write(rv) or return :close end - end while true - end + end while @hs.headers? return response_hijacked(hijack) if hijack return http_response_done(alive) if hdr_only diff --git a/test/test_rack_hijack.rb b/test/test_rack_hijack.rb index 671387e..c878552 100644 --- a/test/test_rack_hijack.rb +++ b/test/test_rack_hijack.rb @@ -86,6 +86,12 @@ def test_hijack assert_equal "rack.input contents: BLAH", res.body assert_equal 201, res.code.to_i assert_equal "1.0", res.http_version + + # ancient "HTTP/0.9" + c = get_tcp_client(host, port) + c.write("GET /hijack_res\r\n\r\n") + res = Timeout.timeout(30) { c.read } + assert_equal 'response.hijacked', res ensure quit_wait(pid) end -- EW
reply other threads:[~2016-11-29 21:05 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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/yahns/README * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20161129210516.GA11386@starla \ --to=e@80x24.org \ --cc=yahns-public@yhbt.net \ --subject='Re: [PUSHED] http_response: support rack.hijack on HTTP/0.9 responses' \ /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
Code repositories for project(s) associated with this inbox: ../../yahns.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).