Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96251 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67675 invoked from network); 5 Oct 2016 16:15:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Oct 2016 16:15:03 -0000 X-Host-Fingerprint: 94.2.241.23 unknown Received: from [94.2.241.23] ([94.2.241.23:4729] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A2/F4-23443-50725F75 for ; Wed, 05 Oct 2016 12:15:03 -0400 Message-ID: To: internals@lists.php.net References: <1de78ecd-74e5-438c-9744-103163218ebd@gmail.com> Date: Wed, 5 Oct 2016 17:14:57 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:43.0) Gecko/20100101 Firefox/43.0 SeaMonkey/2.40 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: 7bit X-Posted-By: 94.2.241.23 Subject: Re: Add support for HTTP/1.1 From: ajf@ajf.me (Andrea Faulds) Hi Rowan, Rowan Collins wrote: > 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. HTTP/1.1 ought to be the default now, I think. The lack of the Host: header in HTTP/1.0 is pretty serious given how much of the web runs on vhosts now. > 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 don't know about ones you've missed, but the Host header, persistent connections and chunked transfer were the main ones that caught me out when I wrote my own minimal HTTP client a while ago. In order to connect to many modern websites, you need a Host: header, and in order to use a Host: header, you need to use HTTP/1.1 (if you don't, servers will sometimes send you back a 1.1 response anyway!). In order to understand the output of those servers, you may need chunked transfer encoding, particularly if they're running dynamic code (say, PHP), and you need to specify the connection is non-persistent, lest you wait forever. > What do people think? Would this be a worthwhile effort? I think it's the absolute minimum we need to do to have it work properly at all. Using HTTP/1.0 alone probably means PHP's HTTP stream wrapper support is effectively broken at present, if my experiences are anything to go by. Thanks for bringing this up! -- Andrea Faulds https://ajf.me/