# [RFC] [DISCUSSION] pecl_http

- Thread: https://externals.io/message/81370
- Original archive: https://news-web.php.net/php.internals/81370
- Started by Michael Wallner on 2015-01-29T11:14:13+00:00
- Messages: 48
- Page 1 of 2: messages 1 to 25 (25 per page, add `?page=N` to the URL)
- Next page: https://externals.io/message/81370.md?page=2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #81370 — Michael Wallner — 2015-01-29T11:14:13+00:00

URL: https://externals.io/message/81370#81370

Hi!

I’ve rewritten the RFC for pecl_http and hopefully addressed most of the things mentioned previously.

I you still find anything lacking, please let me know, so I can expand the RFC accordingly.

And of course, everything else is up for discussion.

Thanks,
Mike

---

## #81371 — Yasuo Ohgaki — 2015-01-29T11:32:05+00:00

URL: https://externals.io/message/81370#81371 · In reply to: #81370

Hi Mike,

Awesome work!



> I’ve rewritten the RFC for pecl_http and hopefully addressed most of the
> things mentioned previously.
>
> I you still find anything lacking, please let me know, so I can expand the
> RFC accordingly.
>
> And of course, everything else is up for discussion.
>

https://wiki.php.net/rfc/pecl_http

The URL is this, right?

--
Yasuo Ohgaki
yohgaki@ohgaki.net

---

## #81372 — Michael Wallner — 2015-01-29T11:38:26+00:00

URL: https://externals.io/message/81370#81372 · In reply to: #81371

> Hi Mike,
> 
> Awesome work!
> 
> On Thu, Jan 29, 2015 at 8:14 PM, Michael Wallner <mike@php.net
> <mailto:mike@php.net>> wrote:
> 
>     I’ve rewritten the RFC for pecl_http and hopefully addressed most of
>     the things mentioned previously.
> 
>     I you still find anything lacking, please let me know, so I can
>     expand the RFC accordingly.
> 
>     And of course, everything else is up for discussion.
> 
> 
> https://wiki.php.net/rfc/pecl_http
> 
> The URL is this, right?

Yes, of course! Bad mistake, sorry.


-- 
Regards,
Mike

---

## #81373 — Andrea Faulds — 2015-01-29T11:40:50+00:00

URL: https://externals.io/message/81370#81373 · In reply to: #81370

Hi Mike,

> 
> 
> I’ve rewritten the RFC for pecl_http and hopefully addressed most of the things mentioned previously.
> 
> I you still find anything lacking, please let me know, so I can expand the RFC accordingly.

The RFC is an improvement in that it covers more of *what* pecl/http is, but it still doesn’t answer the most important question: why? It still doesn’t answer any of the following key questions:

* Why do we need pecl/http?
  * Why should pecl/http be merged into PHP core?
  * Why should pecl/http be enabled by default?
  * Why should we have our own HTTP API and not follow PSR-7?
  * What does it offer over PHP’s existing HTTP capabilities?
  * Why should we merge this rather than, say, filling in gaps in PHP’s HTTP capabilities?

So, I think the RFC is still rather lacking. The Features section isn’t really any better than before, either. It only gives a sentence or two to each module, which isn’t terribly informative. Each module probably needs its own rationale, and a comparison to PHP’s existing facilities, as well.

Thanks.

--
Andrea Faulds
http://ajf.me/

---

## #81374 — Lester Caine — 2015-01-29T12:01:46+00:00

URL: https://externals.io/message/81370#81374 · In reply to: #81373

> * Why do we need pecl/http?
> * Why should pecl/http be merged into PHP core?
> * Why should pecl/http be enabled by default?
> * Why should we have our own HTTP API and not follow PSR-7?
> * What does it offer over PHP’s existing HTTP capabilities?
> * Why should we merge this rather than, say, filling in gaps in PHP’s HTTP capabilities?

On one hand third party packages are being pushed in place of the
existing built in functions. Here a new set of built in functions are
being proposed. Having used Apache for many years and now moved to Nginx
as my 'interface', just where does this fit into the overall jigsaw.
Using Nginx to handle the static stuff and only passing dynamic calls to
php_fpm, just what http functionality is needed?

The main reason for asking this question actually relates to
implementing a server for tzdist which I can easily handle with the
Nginx/php_fpm framework, and that should serve static pages until a
change of version requires building a new data set. Is this the sort of
process that can be handled totally within PHP and does that actually
make sense where a large volume of static data is cached?

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #81375 — Crypto Compress — 2015-01-29T12:18:26+00:00

URL: https://externals.io/message/81370#81375 · In reply to: #81373

> * Why should we have our own HTTP API and not follow PSR-7?

possible points:
- PHP-FIG propose no implementations; pecl_http does
- PHP-FIG focus on frameworks; pecl_http in core is useable without 
dependencies by every simple script
- PSR-7 is a moving target; pecl_http exists for ten years
- PSR-7 can be complementary to pecl_http not the other way around (c 
code can't use php code?)
- native implementations should be faster

---

## #81377 — Andrea Faulds — 2015-01-29T12:40:30+00:00

URL: https://externals.io/message/81370#81377 · In reply to: #81375

> 
> 
> 
> > […]
> 
> possible points:
> - PHP-FIG propose no implementations; pecl_http does
> - native implementations should be faster

I don’t see how that’s relevant: I’m talking here about the API, not the implementation. Why should PHP’s HTTP API not be PSR-7?

> - PHP-FIG focus on frameworks; pecl_http in core is useable without dependencies by every simple script

Also irrelevant, there’s no reason it couldn’t use PSR-7’s API.

> - PSR-7 is a moving target; pecl_http exists for ten years

Fair point.

> - PSR-7 can be complementary to pecl_http not the other way around (c code can't use php code?)

Not necessarily true.
--
Andrea Faulds
http://ajf.me/

---

## #81384 — Larry Garfield — 2015-01-29T18:11:24+00:00

URL: https://externals.io/message/81370#81384 · In reply to: #81377

>
> > […]
>
> I don’t see how that’s relevant: I’m talking here about the API, not the implementation. Why should PHP’s HTTP API not be PSR-7?
>
> > […]
>
> Also irrelevant, there’s no reason it couldn’t use PSR-7’s API.
>
> > […]
>
> Fair point.
>
> > […]
>
> Not necessarily true.
> --
> Andrea Faulds
> http://ajf.me/

In my rainbows and ponies vision of the future, it would go something 
like this:

1) PSR-7 is approved.  People use it.  People love it.

2) Internals makes internal definitions of the interfaces from PSR-7, 
renamed to a PHP namespace but otherwise identical.  Eg:

\Php\Http\Message
\Php\Http\Request
\Php\Http\Response
\Php\Http\ServerRequest

FIG makes available an alternate set of interfaces that are PSR-7 but 
extent the internal ones for type hint compatibility.

Someone (FIG, internals, me?) makes a user-space definition of the new 
internals interfaces as a BC layer.

3) Internals improves its userspace stream APIs such that the 
StreamInterface from PSR-7 can be retired completely.  (It exists almost 
entirely as a way to avoid dealing with the PHP-native stream APIs.)

4) Internals adds a function/routine/thing to spawn a ServerRequest that 
is equivalent to the user-space code to create a PSR-7 ServerRequest out 
of the superglobals.  It is, of course, faster than doing in userspace 
and also more standard.  Internals also adds a "send this response 
object to this stream (default stdout)" routine.

5) Everyone switches over to using the Internals-named interfaces and 
ServerRequest builder. Because the interface is the same aside from the 
name this is about a 5 minute task per project and could be done by a 
small shell script.

6) Internals build a simple HTTP client that uses \Php\Http directly. 
It's probably not as powerful as Guzzle et al but easily extensible. 
Because user-space clients are already using those interfaces, that 
makes swapping the new Internals one in instead is a really easy task. 
Guzzle et al can convert to being extensions on the core one, all using 
the common interfaces.

7) The Ewoks, they dance!

I don't expect it will happen exactly like that, of course, but the 
closer we can get to that sort of chain of events the better I think it 
will be for everyone.

Note that the interface definition parts are separate from the writing 
of the HTTP client.  I think it's important to address those two 
separately.  SRP applies to RFCs just as much as code. :-)

--Larry Garfield

---

## #81386 — Michael Wallner — 2015-01-29T20:25:35+00:00

URL: https://externals.io/message/81370#81386 · In reply to: #81370

> 
> 
> Hi!
> 
> I’ve rewritten the RFC for pecl_http and hopefully addressed most of the things mentioned previously.
> 
> I you still find anything lacking, please let me know, so I can expand the RFC accordingly.
> 
> And of course, everything else is up for discussion.

Just a tiny note: I expanded the features section a bit.

https://wiki.php.net/rfc/pecl_http#features <https://wiki.php.net/rfc/pecl_http#features>

Regards,
Mike

---

## #81387 — Yasuo Ohgaki — 2015-01-29T21:01:27+00:00

URL: https://externals.io/message/81370#81387 · In reply to: #81375

Hi all,

On Thu, Jan 29, 2015 at 9:18 PM, Crypto Compress <
cryptocompress@googlemail.com> wrote:

> possible points:
> - PHP-FIG propose no implementations; pecl_http does
> - PHP-FIG focus on frameworks; pecl_http in core is useable without
> dependencies by every simple script
> - PSR-7 is a moving target; pecl_http exists for ten years
> - PSR-7 can be complementary to pecl_http not the other way around (c code
> can't use php code?)
> - native implementations should be faster
>

General pros

 - PHP is made for Web. API like pecl_http should be included by default.
 - Script implementation and module implementation can co-exists. Example
is mail/imap.

Now I understand why many people dislike this proposal probably.
Native module/script implementations may exist both. New module
may be added/replaced at any time if it's required/reasonable.

Regards,

--
Yasuo Ohgaki
yohgaki@ohgaki.net

---

## #81427 — Michael Wallner — 2015-01-30T13:45:17+00:00

URL: https://externals.io/message/81370#81427 · In reply to: #81386

> 
> > […]

Update:

Removed optional dependencies on all three extensions (json, iconv,
hash), and the one INI entry related to it. ETags of dynamic response
bodies would now always be just sha1 hashes.

https://wiki.php.net/rfc/pecl_http#dependencies

-- 
Regards,
Mike

---

## #81429 — Ferenc Kovacs — 2015-01-30T14:08:59+00:00

URL: https://externals.io/message/81370#81429 · In reply to: #81427

> 
> > […]
>
> Update:
>
> Removed optional dependencies on all three extensions (json, iconv,
> hash), and the one INI entry related to it. ETags of dynamic response
> bodies would now always be just sha1 hashes.
>
> https://wiki.php.net/rfc/pecl_http#dependencies
>
> --
> Regards,
> Mike
>
> --
> 
> 
>
>
hi,

just a small question: what will be the upgrade path for existing pecl_http
users upgrading to 7.0?
if we would just move the current ext as is into php-src it would be no
problem for them, but based on the recent discussion that is unlikely and
if we change the userland api they will be forced to upgrade their code
(except if we are willing to provide a php7 compatible version of pecl_http
on pecl.php.net, but I think that would be a PITA for everybody).
ofc. this isn't a blocker problem, but something we should keep in mind.

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu

---

## #81431 — Michael Wallner — 2015-01-30T14:22:27+00:00

URL: https://externals.io/message/81370#81431 · In reply to: #81429

> 
> 
> On Fri, Jan 30, 2015 at 2:45 PM, Michael Wallner <mike@php.net
> <mailto:mike@php.net>> wrote:
> 
> > […]

> hi,
> 
> just a small question: what will be the upgrade path for existing
> pecl_http users upgrading to 7.0?

I'd consider PHP7's http extension a new major version, i.e. v3.

> if we would just move the current ext as is into php-src it would be no
> problem for them, but based on the recent discussion that is unlikely
> and if we change the userland api they will be forced to upgrade their
> code (except if we are willing to provide a php7 compatible version of
> pecl_http on pecl.php.net <http://pecl.php.net>, but I think that would
> be a PITA for everybody).

I definitley would stay away from having a separate PHP7 compatible PECL
version, but coming v2 releases could take measures to prepare any
transition to the PHP7 API.

> ofc. this isn't a blocker problem, but something we should keep in mind.

Alas, not much has changed so far:

 - no automatic `json_decode()` into $_POST:

	I doubt anybody used that


 - default etag hash algo for dynamic response bodies has changed to
   sha1 from crc32 and cannot be changed through an INI setting

	etags on dynamic content are, well, subject to change anyway,
	so I don't see major troubles


 - missing http\QueryString::xlate()

	This is a real BC break, though.


-- 
Regards,
Mike

---

## #81439 — Lester Caine — 2015-01-30T16:45:47+00:00

URL: https://externals.io/message/81370#81439 · In reply to: #81431

>  - default etag hash algo for dynamic response bodies has changed to
>    sha1 from crc32 and cannot be changed through an INI setting
> 
> 	etags on dynamic content are, well, subject to change anyway,
> 	so I don't see major troubles

I presume that a calculated etag value can be returned as an
alternative. Something dictated by the service using this facility?
There is provision for the etag value being a version number or some
similarly defined value.

-- 
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

---

## #81441 — Michael Wallner — 2015-01-30T17:06:53+00:00

URL: https://externals.io/message/81370#81441 · In reply to: #81439

> 
> > […]
> 
> I presume that a calculated etag value can be returned as an
> alternative. Something dictated by the service using this facility?
> There is provision for the etag value being a version number or some
> similarly defined value.
> 

Definitely:
http://devel-m6w6.rhcloud.com/mdref/http/Env/Response/setEtag

-- 
Regards,
Mike

---

## #81447 — Stanislav Malyshev — 2015-01-30T19:10:27+00:00

URL: https://externals.io/message/81370#81447 · In reply to: #81370

Hi!

> I’ve rewritten the RFC for pecl_http and hopefully addressed most of the things mentioned previously.

Thank you, Michael, this is much better!

I would still like to hear more about 2 extensions, especially about
raphf - it seems to be some framework for handling persistent resources,
but it's not clear why we need persistent resources for HTTP module at
all (who keeps HTTP connections open between requests?) and the code in
the example doesn't show any significant logic there - it just basically
wraps curl functions, so I wonder why we need whole new API in core for
that?

About propro - it says that it improves by-reference access to handler
properties, which may be useful but I don't really see how it relates to
HTTP module either - why would you need by-ref access in this context?
Could you give any example of a common code pattern that was impossible
without it but is enabled with it?

-- 
Stas Malyshev
smalyshev@gmail.com

---

## #81454 — Michael Wallner — 2015-01-30T19:40:36+00:00

URL: https://externals.io/message/81370#81454 · In reply to: #81447

Hi Stas!


> Hi!
> 
> > […]
> 
> Thank you, Michael, this is much better!
> 
> I would still like to hear more about 2 extensions, especially about
> raphf - it seems to be some framework for handling persistent resources,
> but it's not clear why we need persistent resources for HTTP module at
> all (who keeps HTTP connections open between requests?) and the code in
> the example doesn't show any significant logic there - it just basically
> wraps curl functions, so I wonder why we need whole new API in core for
> that?

API consumers jump into mind f.e. libcurl caches connections itself, so,
we're just re-using functionality from curl... with lots of good extras,
like cached DNS entries, maybe TLS sessions etc.

I also use it in pecl/pq a PostgreSQL client, which seems a perfect fit
to me, i.e. any database extension not exposing its database handle as a
userland resource should use raphf over zend_list IMO. But Dmitry or any
other expert might of course want to say a few better words about zend_list.

raphf comes with what's needed to maintain (persistent) service handles
within objects. As already explained, we don't need extra refcounting
because the objects are already refcounted, but we could need support
for handle copy ctors to easily support object cloning, still manually,
but without mind boggling code.

The benefit of retire and wakeup handlers are already shown in the RFC,
additionally, check out the resource factory ops of pecl/pq here:
https://github.com/php/pecl-database-pq/blob/master/src/php_pqconn.c#L520-L561

Nothing super-complicated either; though, a copy constructor is not
implemented, but that might only be a matter of creating a new
connection with information out of PQconninfo().

I guess the brave one could implement similar stuff for zend_list, but
all this zend_resource business is useless for interal handles.

> About propro - it says that it improves by-reference access to handler
> properties, which may be useful but I don't really see how it relates to
> HTTP module either - why would you need by-ref access in this context?
> Could you give any example of a common code pattern that was impossible
> without it but is enabled with it?

It doesn't improve it, it yet makes it possible. It's an aid for
internal classes that expose properties to userland that actually
represent state stored in foreign C struct members, and not in the zvals
in the properties table.

Hope that sounds sane in any way?!


-- 
Regards,
Mike

---

## #81813 — Michael Wallner — 2015-02-04T13:00:23+00:00

URL: https://externals.io/message/81370#81813 · In reply to: #81370

Hi!

Do we want to discuss anything further before I put this to vote again?

https://wiki.php.net/rfc/pecl_http

Points explicitely marked for discussion in the RFC itself:

* pecl/propro
  Proxies for properties representing state in internal C structs
  https://wiki.php.net/rfc/pecl_http#peclpropro

* pecl/raphf
  (Persistent) handle management within objects instead of resources
  https://wiki.php.net/rfc/pecl_http#peclraphf
  Also, take special note of the INI setting:
  https://wiki.php.net/rfc/pecl_http#raphf_ini_setting

* POST parsing disregarding request method, solely based on content-type
  https://wiki.php.net/rfc/pecl_http#rinit

JFYI, I've create a POC for HTTP2 support:
http://git.php.net/?p=pecl/http/pecl_http.git;a=shortlog;h=refs/heads/http2-poc

This is for PHP5, though, and needs a recent libcurl built with nghttp2
support.

-- 
Regards,
Mike

---

## #81814 — pajousek@gmail.com — 2015-02-04T13:06:04+00:00

URL: https://externals.io/message/81370#81814 · In reply to: #81813

> Hi!
>
> Do we want to discuss anything further before I put this to vote again?
>
> https://wiki.php.net/rfc/pecl_http
>
> Points explicitely marked for discussion in the RFC itself:
>
> * pecl/propro
>   Proxies for properties representing state in internal C structs
>   https://wiki.php.net/rfc/pecl_http#peclpropro
>
> * pecl/raphf
>   (Persistent) handle management within objects instead of resources
>   https://wiki.php.net/rfc/pecl_http#peclraphf
>   Also, take special note of the INI setting:
>   https://wiki.php.net/rfc/pecl_http#raphf_ini_setting
>
> * POST parsing disregarding request method, solely based on content-type
>   https://wiki.php.net/rfc/pecl_http#rinit
>
> JFYI, I've create a POC for HTTP2 support:
> http://git.php.net/?p=pecl/http/pecl_http.git;a=shortlog;h=refs/heads/http2-poc
>
> This is for PHP5, though, and needs a recent libcurl built with nghttp2
> support.
>
> --
> Regards,
> Mike
>
> --
> 
> 
>


Hello,

as I mentioned already in the other thread - there are currently no
coding standards related to namespace naming in
https://github.com/php/php-src/blob/master/CODING_STANDARDS and the
coding standards should probably be updated before voting, since this
extension contains namespaces.

Regards
Pavel Kouril

---

## #81815 — Michael Wallner — 2015-02-04T13:17:31+00:00

URL: https://externals.io/message/81370#81815 · In reply to: #81814

> Hello,
> 
> as I mentioned already in the other thread - there are currently no
> coding standards related to namespace naming in
> https://github.com/php/php-src/blob/master/CODING_STANDARDS and the
> coding standards should probably be updated before voting, since this
> extension contains namespaces.

Do we agree that namespaces should follow how class names look?
So, I guess it would be Http, or maybe HTTP since it's an abbreviation.


-- 
Regards,
Mike

---

## #81816 — Pierre Joye — 2015-02-04T13:21:37+00:00

URL: https://externals.io/message/81370#81816 · In reply to: #81815

>
> 
>
> > […]
>
> Do we agree that namespaces should follow how class names look?
> So, I guess it would be Http, or maybe HTTP since it's an abbreviation.
>
>
I would go with Http\

---

## #81823 — Crypto Compress — 2015-02-04T17:10:23+00:00

URL: https://externals.io/message/81370#81823 · In reply to: #81816

> I would go with Http\

Why not the reserved Php\Http\?

---

## #81824 — Andrea Faulds — 2015-02-04T17:17:16+00:00

URL: https://externals.io/message/81370#81824 · In reply to: #81823

Hey,

> 
> 
> > […]
> 
> Why not the reserved Php\Http\?

This sounds good to me. php\ is already reserved, and it’s similar to the common community convention of vendor\packagename. (e.g. ajf\escapes.) Would work well with Composer and Packagist too, as it could be a virtual php/http package (Packagist naming convention).

Also, I’d like to say I’d prefer php\HTTP or php\http over php\Http. Capitalising an acronym doesn’t feel right to me, perhaps because case is usually significant, Following the Casing Rules Used by Titles. Of php\HTTP and php\http, php\http is probably better since the case matches that of php\. It could also be PHP\HTTP, I guess, but lowercase is somehow more appealing to me.

Thoughts?
--
Andrea Faulds
http://ajf.me/

---

## #81825 — Andrey Andreev — 2015-02-04T17:23:41+00:00

URL: https://externals.io/message/81370#81825 · In reply to: #81824

Hi,


> Hey,
>
> > […]
>
> This sounds good to me. php\ is already reserved, and it’s similar to the common community convention of vendor\packagename. (e.g. ajf\escapes.) Would work well with Composer and Packagist too, as it could be a virtual php/http package (Packagist naming convention).
>
> Also, I’d like to say I’d prefer php\HTTP or php\http over php\Http. Capitalising an acronym doesn’t feel right to me, perhaps because case is usually significant, Following the Casing Rules Used by Titles. Of php\HTTP and php\http, php\http is probably better since the case matches that of php\. It could also be PHP\HTTP, I guess, but lowercase is somehow more appealing to me.
>
> Thoughts?

I'm not sure about namespacing it in the first place, but otherwise I
agree with you - acronyms should be capitalised.

Some <put a popular styleguide here> nazis probably won't agree, but
capitalising only the first letter of an acronym does feel really
weird.

Cheers,
Andrey.

---

## #81827 — Andrea Faulds — 2015-02-04T17:26:34+00:00

URL: https://externals.io/message/81370#81827 · In reply to: #81825

Hey,

> 
> 
> I'm not sure about namespacing it in the first place, but otherwise I
> agree with you - acronyms should be capitalised.

What’s your objection? We either namespace it, or we have to add some weird prefix to avoid conflicts. I’d rather we not have the prefix.

The global namespace is already plenty polluted. Sure, most extensions so far don’t use namespaces, but that’s because they were written before 5.3 came out. I think it’s time to move on. Users know what namespaces are now, I don’t think it’d cause problems.

Thanks.
--
Andrea Faulds
http://ajf.me/

---

Next page: https://externals.io/message/81370.md?page=2
