Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96210 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23253 invoked from network); 4 Oct 2016 08:55:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Oct 2016 08:55:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=bjorn.x.larsson@telia.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=bjorn.x.larsson@telia.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain telia.com from 81.236.60.156 cause and error) X-PHP-List-Original-Sender: bjorn.x.larsson@telia.com X-Host-Fingerprint: 81.236.60.156 v-smtpout3.han.skanova.net Received: from [81.236.60.156] ([81.236.60.156:33615] helo=v-smtpout3.han.skanova.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CE/1D-06241-56E63F75 for ; Tue, 04 Oct 2016 04:55:02 -0400 Received: from [192.168.7.7] ([195.198.188.252]) by cmsmtp with SMTP id rLV4bzNKibpfNrLV4b9EC1; Tue, 04 Oct 2016 10:54:58 +0200 To: Rowan Collins References: <1de78ecd-74e5-438c-9744-103163218ebd@gmail.com> Cc: PHP Internals Message-ID: <897130ff-431f-b4d0-fa2d-1c74a50d595b@telia.com> Date: Tue, 4 Oct 2016 10:55:05 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <1de78ecd-74e5-438c-9744-103163218ebd@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4wfG+FMshBwVsi/u8rrsNHNYPOBm6qg1nx3Tf74Mqip6G9/b8D/3lzInE+UGfV9yNvtM3E+qV4oSJVK0fsf/CCEbYmlvgeezZBC5wHX0wXuS/H6HXeoS/S VG/9X7UDwqzBoTIc9RYWoySgYXDdOe3W5t7PBUY5rl2Qcq4jDMOLLo3gs+i5X4OKQ83/HLrt685HkZ+0jEXmPI04psslPuekr1QfIhBFTWqvJz79rIZRzJld Subject: Re: [PHP-DEV] Add support for HTTP/1.1 From: bjorn.x.larsson@telia.com (=?UTF-8?Q?Bj=c3=b6rn_Larsson?=) Den 2016-10-02 kl. 23:12, skrev Rowan Collins: > Hi internallers! > > No, you haven't misread the subject line, I'm not talking about the > exciting new HTTP/2, but HTTP/1.1, 20 years old this year. > > To my surprise, PHP's HTTP stream wrapper (e.g. > file_get_contents('http://example.com');) defaults to sending HTTP/1.0 > requests. You can tell it to use HTTP/1.1 with an appropriate "stream > context", but it's fiddly [1], and the implementation is incomplete. > > There's actually already an exception to this: some SOAP servers were > discovered to only talk HTTP/1.1, so ext/soap forces the wrapper to > upgrade by default [bug-43069]. This in turn revealed some of the bugs > in the wrapper's protocol support, one of which I have recently > created a patch for [bug-47021]. > > It's reasonable to suppose that 9 years on from that bug those SOAP > servers aren't alone in rejecting (or mishandling) HTTP/1.0 requests, > and moves to implement HTTP/2.0 will only make that more likely. > > I think it would be good to get this support into a better state, make > it easier to switch on - e.g. with an INI setting, or some new stream > URL syntax - and possibly make HTTP/1.1 the default in PHP 8.0. > > > As I understand it, supporting HTTP/1.1 as a client requires the > following mandatory features on top of HTTP/1.0: > > a) Send a "Host" header with every request. (RFC 7230 Section 5.4) > b) Support persistent connections, or send "Connection: Close" with > each request. (RFC 7230 Section 6.1) > c) Ignore 1xx status lines (notably, "100 Continue") "even if the > client does not expect one" (RFC 7231 Section 6.2) > d) Support "chunked" transfer encoding (RFC 7230 Section 4.1) > > Let me know if there are any I've missed. > > I believe this is the current state of the PHP implementation: > > a) Host header always sent regardless of protocol version. > b) The SOAP wrapper explicitly generates a "Connection: Close" header > as well as forcing HTTP/1.1; users need to set it as a further option > in stream_context_create(). It would be better if this was implicit > with the protocol version. > c) I can't find a bug report for this, but 100 Continue appears to be > treated as an error status. This should be fixed. > d) Chunked encoding itself was implemented, but the code for parsing > headers was broken. If my PR [pr-1902] is approved, this will > hopefully work correctly. > > > What do people think? Would this be a worthwhile effort? > > [1]: Sample HTTP/1.1 context > https://gist.github.com/IMSoP/8c62c97afc8765f418468b28a501409e > [bug-43069]: https://bugs.php.net/bug.php?id=43069 > [bug-47021]: https://bugs.php.net/bug.php?id=47021 > [pr-1902]: https://github.com/php/php-src/pull/1902 > > Regards, > Yup, personally I do find this a worthwhile effort! Would fixing this behaviour also be applicable for HTTPS? Regards //Björn Larsson