rfc:pecl_http

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:pecl_http [2015/01/29 11:13] – typo mikerfc:pecl_http [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== PHP RFC: Add pecl_http to core ====== ====== PHP RFC: Add pecl_http to core ======
-  * Version: 2.0 +  * Version: 2.4 
-  * Date: 2015-01-29+  * Date: 2014-08-19 
 +  * Last-Modified: 2015-02-20
   * Author: Michael Wallner, <mike@php.net>   * Author: Michael Wallner, <mike@php.net>
-  * Status: Discussion+  * Status: Declined
   * First Published at: http://wiki.php.net/rfc/pecl_http   * First Published at: http://wiki.php.net/rfc/pecl_http
  
 ===== Introduction ===== ===== Introduction =====
-It was interesting to see so many “users” that know pecl_http and so many “developers” that had no clue, so let’s start early. 
  
 ==== About ==== ==== About ====
Line 32: Line 32:
  
 === Test coverage === === Test coverage ===
-The current test suite provides a code coverage of about 90% and is subject to improvement. \\ Coverage resport of v2: http://dev.iworks.at/ext-http/lcov/http/index.html +The current test suite provides a code coverage of about 90% and is subject to improvement. \\ Coverage resport of v2: http://dev.iworks.at/ext-http/lcov/ext/http/index.html 
  
 There’s one test that currently fails for me due to porting the extension to ZE3, because of reference mismatch and a leak in zend_assign_to_variable_ref() as cause. There’s one test that currently fails for me due to porting the extension to ZE3, because of reference mismatch and a leak in zend_assign_to_variable_ref() as cause.
Line 43: Line 43:
  
 ===== The Guts ===== ===== The Guts =====
-A fully merged tree can be inspected here: \\ https://github.com/m6w6/php-src/tree/merge-http+A fully merged tree can be inspected here (based on v2.2, so slightly out of date): \\ https://github.com/m6w6/php-src/tree/merge-http 
 + 
 +An up-to-date (based on v2.3) pecl_http tree for PHP7 can be found here: \\ https://github.com/php/pecl-http-pecl_http/tree/phpng
  
 ==== Documentation ==== ==== Documentation ====
Line 55: Line 57:
      
 ==== Dependencies ==== ==== Dependencies ====
-=== zlib ===+=== libz AKA zlib ===
   * Type: of dep: hard build dep   * Type: of dep: hard build dep
   * Minimum version: 1.2.0.4   * Minimum version: 1.2.0.4
Line 76: Line 78:
   * Provided functionality: multi_socket API from libcurl   * Provided functionality: multi_socket API from libcurl
   * Current state: nice to have - must have for more parallel requests than select() can reasonably handle; might look into additional alternatives like libuv (libev already has libevent compatibility)   * Current state: nice to have - must have for more parallel requests than select() can reasonably handle; might look into additional alternatives like libuv (libev already has libevent compatibility)
- 
-=== ext/json === 
-  * Type of dep: soft build dep 
-  * Provided functionality: decode application/json request bodies into $_POST 
-  * Current state: suspect to removal, please discuss 
-  * Affected code: https://github.com/php/pecl-http-pecl_http/blob/phpng/php_http_env.c#L939-L984 
- 
-=== ext/iconv === 
-  * Type of dep: soft build dep 
-  * Provided functionality: translate x-www-form-urlencoded data to other character sets 
-  * Current state: suspect to removal, please discuss 
-  * Affected code: https://github.com/php/pecl-http-pecl_http/blob/phpng/php_http_querystring.c#L86-L140 
- 
-=== ext/hash === 
-  * Type of dep: soft build dep 
-  * Provided functionality: creating ETags for dynamic response bodies 
-  * Current state: suspect to removal, please discuss 
-  * Affected code: https://github.com/php/pecl-http-pecl_http/blob/phpng/php_http_etag.c#L36-L43 \\ https://github.com/php/pecl-http-pecl_http/blob/phpng/php_http_etag.c#L79-L86 \\ https://github.com/php/pecl-http-pecl_http/blob/phpng/php_http_etag.c#L79-L86 
  
 === pecl/propro === === pecl/propro ===
Line 365: Line 349:
 Most of the features are directly accessible through pecl_http's C API. Most of the features are directly accessible through pecl_http's C API.
  
-=== INI === +=== Globals === 
-Additionally to the INI setting of raphfthere’s http.etag.mode (USER, defaults to crc32b), defining a hash algo used to generate ETags for dynamic response bodies. It may be better to make this a property of the actual http\Env\Response instead of a global setting, please discuss.+Nothing in the global namespaceexcept the namespace ''Http''.
  
-=== RINIT === +== Client == 
-The http\Env module kicks the POST parser regardless of the request method, only the right content type of x-www-form-urlencoded or form-data must be given.+  * Docs: http://devel-m6w6.rhcloud.com/mdref/http/Client 
 +  * Current status: essential 
 +  * Related functionality in core: HTTP stream wrapper, ext/curl
  
-I suspect this is a controversial featureso I’m listing it separately: \\ https://github.com/php/pecl-http-pecl_http/blob/phpng/php_http_env.c#L16-L69+The HTTP stream wrapper is of limited functionalitybut may work for most simple needs
  
-The ''FIX-ME'' note about the leak is already irrelevantthough.+Better support for more complicated applications like different authentication schemesproxy types, encodings, SSL/TLS layers and what not is a desirable out of the box functionality.
  
-If accepted, it would be easier to ditch this RINIT and just lift the request method limitation.+All of that would actually be available by ext/curl but the existing libcurl binding is in an subpar maintenance state and suffers from its own quirks. Also, to my great surprise, there are only about five people enjoying the libcurl API, or what is available from it in PHP.
  
-=== Globals === +Currently only libcurl is implemented as a provider for http\Clientproviding most of the functionality of most-current libcurl. This should be a good bet, because libcurl is mature and ubiquitously available.This does not mean that we may not implement our own "PHP" driver for http\Client.
-Nothing in the global namespaceexcept the namespace ''http''.+
  
-== Client == +http\Client supports sending parallel requests, optionally driven by an event loop library like libev{,ent}.
-http://devel-m6w6.rhcloud.com/mdref/http/Client+
  
-The http stream wrapper is of limited functionality and the existing libcurl binding is subparThey could be improved separately, but that is not subject of this RFC.+== Encoding == 
 +  * Docs: http://devel-m6w6.rhcloud.com/mdref/http/Encoding/Stream 
 +  * Current status: essential 
 +  * Related functionality in core: ext/zlib
  
-Currently only libcurl is implemented as provider for http\Clientproviding most of the functionality of current libcurl.+Actually ext/zlib supports all the same three encodings since I fixed it few years agoso there could be the occasion for few shared code lines. What it definitely lacks, though, are incremental encoders/decoders not depending on php_streams in form of stream filters.
  
-Representation of the request and response how a client sees them as http\Client\Request and http\Client\Response, extending http\MessageSee http://devel-m6w6.rhcloud.com/mdref/http/Client/enqueue+AFAIK there no accessible implementation of chunked encoding in core.
  
-Support for parallel requests and optional libev{,ent} support. See f.e. http://devel-m6w6.rhcloud.com/mdref/http/Client/once+== Env == 
 +  * Docs: http://devel-m6w6.rhcloud.com/mdref/http/Env 
 +  * Current status: feature completive 
 +  * Related functionality in core: superglobals, php:/ input, output buffering, various functions and bits here and there
  
-== Cookie == +http\Env provides negotiation of content type, character set and language which is a feature set often asked for, nothing comparable exists in core.
-http://devel-m6w6.rhcloud.com/mdref/http/Cookie+
  
-Parses Cookie and Set-Cookie header values. Actually builds on http\Params.+Most of what the environmental/server request constitutes is represented by superglobals and any request body by php://input, which is absolutely no problem, especially since php://input does not point to an allocated string in the SAPI globals (even possibly allocated twice).
  
-== Encoding == +http\Env\Request provides a central access point for all of that data and makes it safe to change/mock it without actually changing the original environment.
-http://devel-m6w6.rhcloud.com/mdref/http/Encoding/Stream+
  
-Streamable implementations of chunked and zlib/gzip/deflate encodings.+http\Env\Response provides features for sending responses beyond header(), ob_start() and readfile() with support for ranges/resuming, caching and throttling.
  
-== Env ==+== Message == 
 +  * Docs: http://devel-m6w6.rhcloud.com/mdref/http/Message 
 +  * Current status: essential 
 +  * Related functionality in core: rfc1867.c
  
-Negotiation facilities, representations of the request and response how the server sees them as http\Env\Request and http\Env\Response+Message parser and tools. http\Message is the base class of all request and response classes. Note that a "parent message" denotes any message appearing before a message in a stream of messages
  
-Support for range requests (resumingand caching by etag/last-modifiedsee f.e. http://devel-m6w6.rhcloud.com/mdref/http/Env/Response/setContentDisposition+Also message bodies with support for building and (basicparsing of multipart bodiesutilizing a (temporary) stream for memory efficiency. 
 + 
 +Splitting a multipart body creates a chain of http\Message objects.
  
 == Header == == Header ==
-http://devel-m6w6.rhcloud.com/mdref/http/Header+  * Docs: http://devel-m6w6.rhcloud.com/mdref/http/Header 
 +  * Current status: essential 
 +  * Related functionionalty in core: non-existent
  
 Header parser and tools. Header parser and tools.
  
-== Message == +I'm really not sure what case I should make about a header and message parser implementation in an HTTP package.
-http://devel-m6w6.rhcloud.com/mdref/http/Message+
  
-Message parser and tools. http\Message is the base class of all request and response classes. Note that a "parent message" denotes any message appearing before a message in a stream of messages, see http://devel-m6w6.rhcloud.com/mdref/http/Message/getParentMessage for calrification. +== Cookie == 
 +  * Docs: http://devel-m6w6.rhcloud.com/mdref/http/Cookie 
 +  * Current status: feature completive, maybe the odd cousin 
 +  * Related functionality in core: non-existent
  
-Also message bodies with support for building and (basic) parsing of multipart bodiesutilizing (temporary) stream for memory efficiency, see f.e. http://devel-m6w6.rhcloud.com/mdref/http/Message/Body/__construct+Cookie and Set-Cookie headers come in a special format and are ubiquitousthus they deserve discrete parser.
  
-Splitting a multipart body creates a chain of http\Message objectssee http://devel-m6w6.rhcloud.com/mdref/http/Message/splitMultipartBody for an example.+One could argue that there is related functionality in corenamely php_default_treat_data(), but it is inaccessible from userland and cumbersome to call internally.
  
 == Params == == Params ==
-http://devel-m6w6.rhcloud.com/mdref/http/Params+  * Docs: http://devel-m6w6.rhcloud.com/mdref/http/Params 
 +  * Current status: essential 
 +  * Related functionality in core: non-existent
  
 Header params parser; think of a content-type or an accept header. Negotiation, cookie and query parser build on it. Header params parser; think of a content-type or an accept header. Negotiation, cookie and query parser build on it.
  
 == QueryString == == QueryString ==
-http://devel-m6w6.rhcloud.com/mdref/http/QueryString+  * Docs: http://devel-m6w6.rhcloud.com/mdref/http/QueryString 
 +  * Current status: feature completive 
 +  * Related functionality in core: parse_str() (php_default_treat_data())
  
 Query string parser and tools. Actually builds on http\Params. Query string parser and tools. Actually builds on http\Params.
 +
 +parse_str() suffers from its legacy/heritage as it replaces f.e. dots with underlines.
  
 == Url == == Url ==
-http://devel-m6w6.rhcloud.com/mdref/http/Url+  * Docs: http://devel-m6w6.rhcloud.com/mdref/http/Url 
 +  * Current status: essential 
 +  * Related functionality in core: parse_url()
  
-Ever been hit by the iscntrl() usage of parse_url()?+URL parser and tools with UTF-8, locale multibyte and IDNA support (need to check if, and how much it diverges from IRIs). See RFC3987 and RFC3988.
  
-URL parser and tools with UTF-8locale multibyte and IDNA support (need to check if, and how much it diverges from IRIs).+I'm not sure what recommendation parse_url() follows, if any.
  
 ==== Unaffected PHP Functionality ==== ==== Unaffected PHP Functionality ====
Line 444: Line 449:
 ===== Vote ===== ===== Vote =====
  
-50%+1 combined "Yes" votes needed for acceptance.+Three way "yes/enabled by default", "yes/disabled by default", "no" where 50%+1 combined "Yes" votes are needed for acceptance
 + 
 +<doodle title="Add pecl_http to the core?" auth="mike" voteType="single" closed="true"> 
 +   * Yes, enabled by default 
 +   * Yes, disabled by default 
 +   * No 
 +</doodle> 
 + 
 +\\  
 +\\  
 +Additional simple vote on the namespace prefix ("http" or "php\http") disregarding the case. 
 + 
 +<doodle title="Namespace prefix for pecl_http" auth="mike" voteType="single" closed="true"> 
 +   * http 
 +   * php\http 
 +</doodle> 
 + 
 +===== Discussed and changed items ===== 
 + 
 +== Parsing multipart/form-data and a/www-form-url-encoded for any request method == 
 + 
 +This functionality was removed from the proposal. 
 + 
 +== Parsing a/json into $_POST == 
 + 
 +This functionality was removed from the proposal, which removed the ext/json dependency. 
 + 
 +== Translating charsets of http\QueryString == 
 + 
 +This functionality was removed from the proposal, which removed the ext/iconv dependency. 
 + 
 +== Extended hashing methods for ETags of dynamic content == 
 + 
 +This functionality was removed from the proposal, which removed the ext/hash dependency. 
 + 
 +== Splitting up into smaller RFCs == 
 + 
 +It was requested to split this RFC up into more smaller ones, but mainly only, as observed by me, to *not* bring an HTTP client implementation into the default distribution. These requests were not considered further by me, because I think the client gives substantial value to the overall package. 
 + 
 +== Upgrade path for existing pecl_http users == 
 + 
 +A pecl_http integraded into the default distribution would be considered v3. Upcoming v2 releases could take measures to prepare any transition to the PHP7 API. 
 + 
 +== Namespace choice, or the case of the case == 
 + 
 +I consider this issue non-important, because we do not rely on the case for internal classes, so ''http'', ''HTTP'' and ''Http'' only have cosmetic effect. 
 + 
 +There will be an extra vote on whether to prefix the ''http'' namespace with ''php''. Here, I consider ''PHP'', ''php'' and ''Php'' to be equal as well.
  
 ===== Changelog ===== ===== Changelog =====
Line 459: Line 511:
   * 2.0   * 2.0
     * Complete rewrite     * Complete rewrite
 +  * 2.1
 +    * Expanded feature section
 +  * 2.2
 +    * Removed optional dependencies on all three extensions (json, iconv, hash), and the one INI entry related to it
 +  * 2.3
 +    * Removed http\Env RINIT section
 +    * Changed namespace from ''http'' to ''Http''
 +    * Fixed some wordings and list formattings
 +  * 2.4
 +    * Added "Discussed and changed items"
rfc/pecl_http.1422530031.txt.gz · Last modified: 2017/09/22 13:28 (external edit)