Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110266 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 70646 invoked from network); 23 May 2020 08:29:14 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 May 2020 08:29:14 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 15D691804C3 for ; Sat, 23 May 2020 00:08:37 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_20, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.179]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 23 May 2020 00:08:36 -0700 (PDT) Received: by mail-yb1-f179.google.com with SMTP id n10so5783520ybn.8 for ; Sat, 23 May 2020 00:08:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5YR7uQQkQb+CaAWSQkqvtkiZe9rVUCSTbI9KHVhRWEQ=; b=TdhvP/xXBRv0hYcAFh/PwHJaBjjHIf3CkLiaD3JZWKzEw1lzfOmq0WxHAtIxH3SJUv pxvIi6FgARgKBJcVZE2KoHcKwH5VEdWeXGfFWtsuXndjxwPIuqiptZZDsFaIv4z0FKEV zrse7gNm3RDFih6uoUYy+q5YYr50W0Xb5o3HyBWDl2B0+qvHG+367/dypEHGDP0vlIVr jf4zq4zLDs8SLyArf9gtip7Ok2uG+kmkvwaM/uZR0Z/3s4kDbMKMVRBGKNSQ2d5taIxM p+HanhkmObGgTqRKNpSAOluPyoAZshwHbhhe5/iv7nFa015yvXJYfq4t/55nooXmvHt6 EcqQ== X-Gm-Message-State: AOAM531YBDBWMIerYiRVQbJeua+UHhmDP0dmdZd3c95wd64MTFyZisB1 xvRgM65nhCpvz0lgvC/6yx5fOCDIp/e/wgV96t8CzQ== X-Google-Smtp-Source: ABdhPJwlx/KCm7ryq6LB+HNBm98jHmunaDKPxPgwvgZgz8uINeiSlnj+WsCPXLGvfkWPqtJ3esQJa1X5eQxivljjxjk= X-Received: by 2002:a05:6902:688:: with SMTP id i8mr28451477ybt.21.1590217715717; Sat, 23 May 2020 00:08:35 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 23 May 2020 00:08:25 -0700 Message-ID: To: Nikita Popov Cc: Rowan Tommins , PHP Internals Content-Type: multipart/alternative; boundary="0000000000000fb39405a64b6a42" Subject: Re: [PHP-DEV] HTTP/1.1 by default in PHP 8.0 From: davey@php.net (Davey Shafik) --0000000000000fb39405a64b6a42 Content-Type: text/plain; charset="UTF-8" dopOn Fri, May 22, 2020 at 3:58 AM Nikita Popov wrote: > On Thu, May 21, 2020 at 11:54 PM Rowan Tommins > wrote: > > > Hi all, > > > > A few years ago, I posted a message suggesting that PHP improve support > > for HTTP/1.1 in its stream wrapper functions: > > https://externals.io/message/96192 > > > > A quick summary of the current situation: > > > > * HTTP/1.1 was officially standardised in January 1997, and most web > > browsers had already implemented it by then > > * PHP has a very simple HTTP client implementation, used by the "http:" > > and "https:" stream wrappers, and also by extensions which make HTTP > > requests, such as ext/soap > > * The client implementation defaults to advertising HTTP/1.0 requests, > > unless over-ridden by a stream context option > > * Since a lot of servers only actually talk HTTP/1.1, the client mostly > > acts as an HTTP/1.1 client even when advertising HTTP/1.0 > > > > > > In my previous message, I identified four requirements in HTTP/1.1 but > > not HTTP/1.0 that are relevant to a client: > > > > 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) > > > > > > The PHP client now supports all four regardless of protocol version > > configured, i.e. it always sends "Host:" and "Connection: Close" > > headers; and always handles "100 Continue" and "Transfer-Encoding: > > Chunked" if returned by the server. > > > > I would like to propose that the client advertises HTTP/1.1 in its > > requests by default in PHP 8.0. Users can opt out of this behaviour in > > a fully backwards- and forwards-compatible way if necessary using a > > stream context option, e.g.: > > https://gist.github.com/IMSoP/a685fed6589435530102d57138755511 > > > > > > What are people's opinions? Does this need an RFC, or should I just > > submit a PR if nobody objects? > > > > Sounds good to me. Assuming there are no objections, feel free to just send > a PR. > > @Eliot: Unfortunately we don't implement HTTP 2 in the http:// stream > wrapper, so HTTP 1.1 is the best we can do there right now. We only provide > HTTP 2 support through the curl extension. Implementing HTTP 2 support > would certainly be a possibility, but I don't think it's particularly easy > to do so without pulling in a dependency like nghttp2. > > @Max: I'm only guessing here, because I'm not familiar with the historical > context, but I imagine part of the motivation is to support HTTP requests > in a minimal build of PHP, which does not have any dependencies (that we do > not bundle ourselves). > > We did actually provide an implementation of the http:// stream wrapper > via > curl for a long time, but dropped it at some point, because there were many > subtle behavior differences to our native implementation. > > Regards, > Nikita > This is ridiculously timely as I've been spending my evening working on HTTP/2 stuff in PHP. This might be a good time to reopen discussion of adding support for HTTP/2 in PHP with the inclusion of libnghttp2. I posted a long time ago about adding support for HTTP/2 to the CLI server and the http stream using libnghttp2 [1]. I think PHP 8.0 would be a perfect opportunity to revisit this given that HTTP/2 has now reached ~97% adoption[2] and HTTP/3 is on the horizon. I believe that HTTP/2 has the potential to dramatically change how we serve content on the web, and PHP should jump on the bandwagon. - Davey [1] https://externals.io/message/89932 [2] https://caniuse.com/#search=http%2F2 --0000000000000fb39405a64b6a42--