Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96193 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48062 invoked from network); 3 Oct 2016 08:43:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Oct 2016 08:43:38 -0000 Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.220 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.220 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.220] ([81.169.146.220:28464] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4F/A3-06241-83A12F75 for ; Mon, 03 Oct 2016 04:43:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1475484213; l=9670; s=domk; d=kelunik.com; h=Content-Type:To:Subject:Date:From:In-Reply-To:References: MIME-Version; bh=BcKhtKKoMpGMTeK6cm1J0X+0mWXzADdKgzoVZB/GZ2U=; b=YSt42HvHOpNrGk/Z4RdW6Vle9Lk2K/K7v/4dFQvLFssDNE0XvTlEyd/OusHMmglvIYv CgiN+qqMYBkEAEkae8QLHy7LunRw+3tM3ROfpmdpS833fJ5EwuRO8uSm1Xj5qDDrmxt1r pnfXwBCgEuqf64UF+UOZ+lLyBUk8/oG4T/c= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mls2vWuiu+7SLGvomb4bl9EfHtO3Q6 X-RZG-CLASS-ID: mo00 Received: from mail-wm0-f47.google.com ([74.125.82.47]) by smtp.strato.de (RZmta 39.5 AUTH) with ESMTPSA id 608101s938hXOtC (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp384r1 with 384 ECDH bits, eq. 7680 bits RSA)) (Client did not present a certificate) for ; Mon, 3 Oct 2016 10:43:33 +0200 (CEST) Received: by mail-wm0-f47.google.com with SMTP id p138so137624440wmb.1 for ; Mon, 03 Oct 2016 01:43:33 -0700 (PDT) X-Gm-Message-State: AA6/9RmAq9pkLJphR7Z5jgPVslhBPhge326TjKtCdiVBvYBGLj7pDZBWfQi+Pwj9fzxLZwv0b8r1LLsmpwUUrg== X-Received: by 10.28.70.70 with SMTP id t67mr7782613wma.35.1475484213492; Mon, 03 Oct 2016 01:43:33 -0700 (PDT) MIME-Version: 1.0 References: <1de78ecd-74e5-438c-9744-103163218ebd@gmail.com> In-Reply-To: <1de78ecd-74e5-438c-9744-103163218ebd@gmail.com> Date: Mon, 03 Oct 2016 08:43:23 +0000 X-Gmail-Original-Message-ID: Message-ID: To: Rowan Collins , PHP Internals Content-Type: multipart/alternative; boundary=94eb2c0d40966ac7e2053df1f09f Subject: Re: [PHP-DEV] Add support for HTTP/1.1 From: me@kelunik.com (Niklas Keller) --94eb2c0d40966ac7e2053df1f09f Content-Type: text/plain; charset=UTF-8 Rowan Collins schrieb am So., 2. Okt. 2016, 23:12: > 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. > I think we already send it starting with 7.0, maybe just for 1.0, because there are some servers that respond correctly with an HTTP/1.1 response to an HTTP/1.0 request, but fail to close the connection and imply "Connection: close" for those requests. 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, > > -- > Rowan Collins > [IMSoP] > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --94eb2c0d40966ac7e2053df1f09f--