[ruby-core:78161] [Ruby trunk Bug#12946] net-http is breaking valid http headers like HTTP2-Settings

From: matthew@...
Date: 2016-11-15 23:29:16 UTC
List: ruby-core #78161
Issue #12946 has been updated by Matthew Kerwin.


Tiago Cardoso wrote:
> The Net::HTTPHeader can't process the `HTTP2-Settings` header, which is a valid header destined to pass base64-encoded settings to a soon-to-be-upgraded-to-http2 connection.

Aren't HTTP header names case-insensitive? What specifically breaks because the string is `"Http2-Settings"`?

----------------------------------------
Bug #12946: net-http is breaking valid http headers like HTTP2-Settings
https://bugs.ruby-lang.org/issues/12946#change-61518

* Author: Tiago Cardoso
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
The Net::HTTPHeader can't process the `HTTP2-Settings` header, which is a valid header destined to pass base64-encoded settings to a soon-to-be-upgraded-to-http2 connection. 

~~~ruby
req=Net::HTTP::Get.new
req["Upgrade"] = "h2c"
req["HTTP2-Settings] = "base64encoded=="

req.to_hash #=> "... Http2-Settings => ..."
~~~

Although one could say that net-http doesn't support to-http2-upgraded connections and even doesn't provide access to the raw socket, it's still a valid HTTP1.1 header, and the headers current MO "force to downcase and store; capitalize on fetch" works against custom Upgrade headers.

As of now, net-http can't upgrade. I'd suggest an API for such things, in that after a successful Upgrade request (101 switch protocols), the http connection "gives up" the socket to something else.  

I had to monkey-patch my way out of this to make my code work: https://github.com/TiagoCardoso1983/jaguar/blob/master/test/test_helper.rb#L16-L25 .



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next