From: lukasaoz@... Date: 2016-11-02T20:58:01+00:00 Subject: [ruby-core:77866] [Ruby trunk Bug#12890] Net::HTTP treats unexpected 1XX responses as final. Issue #12890 has been reported by Cory Benfield. ---------------------------------------- Bug #12890: Net::HTTP treats unexpected 1XX responses as final. https://bugs.ruby-lang.org/issues/12890 * Author: Cory Benfield * Status: Open * Priority: Normal * Assignee: * ruby -v: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin16] * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- Long story short Net::HTTP's client does not tolerate non-100 status codes from the 1XX block in a sensible manner: it treats them as final responses, rather than as provisional ones. Expected behaviour When Net::HTTP receives a 1XX status code that it does not recognise, it should either surface these to a user in such a way that allows the user to access the subsequent final response, or it should ignore them and only show the user the eventual final status code. This is required by RFC 7231 Section 6.2 (Informational 1xx), which reads: > A client MUST be able to parse one or more 1xx responses received prior to a final response, even if the client does not expect one. A user agent MAY ignore unexpected 1xx responses. Actual behaviour Net::HTTP treats the 1XX status code as final. It parses the header block as though it were a response in the 2XX or higher range. Net::HTTP rightly assumes that 1XX responses have no body, which means that it leaves the following 2XX response unconsumed in the socket buffer, which will hide critical data from the user. Steps to reproduce The following Python "server" can demonstrate the issue: ~~~ python import socket import time document = b'''