# Add HTTP/2 Multiplexing-related constants to ext/curl

- Thread: https://externals.io/message/88000
- Original archive: https://news-web.php.net/php.internals/88000
- Started by Davey Shafik on 2015-09-02T05:31:44+00:00
- Messages: 6
- 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

---

## #88000 — Davey Shafik — 2015-09-02T05:31:44+00:00

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

Hi,

I've been poking around at HTTP/2 a lot lately, and it seems that so long
as you are using libcurl 7.43.0+ it's possible to do request multiplexing.

This change simply introduces three constants, `CURLPIPE_NOTHING` (0),
CURLPIPE_HTTP1 (1), and `CURLPIPE_MULTIPLEX` (2) which represent possible
values passed into `curl_multi_setopt()` for the `CURLMOPT_PIPELINING` option.
Current behavior of passing in 0 and 1 map to the first two constants,
while the third allows for multiplexing.

Now, of course, being constants, you can just pass in 0, 1, or 2, but this
brings the consistency and explicitness of exposing them as with all the
other curl constants.

I'd love to see this make it into PHP 7.0 if it's not too late? It's
extremely trivial, but whatever — not that fussed :)

PR is here: https://github.com/php/php-src/pull/1497

I'm not sure if there is some way to ensure that libcurl is compiled with
nghttp, but we don't check for the other HTTP/2 stuff so either it's done
elsewhere and I missed it, or we're making assumptions that the right
version is enough. Any input on this would be good.

FTR, multiplexing can bring substantial performance improvements,
especially when factoring in SSL:

379 HTTP SSL requests

Using HTTP/2 in serial: 63.293796062469 (HTTP/1.1 in serial should be even
slower)
Using HTTP/1.1 with curl_multi: 12.383034944534
Using HTTP/2 w/multiplexing: 2.7933928966522

Thanks,

- Davey

---

## #88001 — Pierre Joye — 2015-09-02T06:03:43+00:00

URL: https://externals.io/message/88000#88001 · In reply to: #88000

Hi,


>
> Hi,
>
> I've been poking around at HTTP/2 a lot lately, and it seems that so long
> as you are using libcurl 7.43.0+ it's possible to do request multiplexing.
>
> This change simply introduces three constants, `CURLPIPE_NOTHING` (0),
> CURLPIPE_HTTP1 (1), and `CURLPIPE_MULTIPLEX` (2) which represent possible
> values passed into `curl_multi_setopt()` for the `CURLMOPT_PIPELINING` option.
> Current behavior of passing in 0 and 1 map to the first two constants,
> while the third allows for multiplexing.
>
> Now, of course, being constants, you can just pass in 0, 1, or 2, but this
> brings the consistency and explicitness of exposing them as with all the
> other curl constants.
>
> I'd love to see this make it into PHP 7.0 if it's not too late? It's
> extremely trivial, but whatever — not that fussed :)
>
> PR is here: https://github.com/php/php-src/pull/1497
>
> I'm not sure if there is some way to ensure that libcurl is compiled with
> nghttp, but we don't check for the other HTTP/2 stuff so either it's done
> elsewhere and I missed it, or we're making assumptions that the right
> version is enough. Any input on this would be good.
>
> FTR, multiplexing can bring substantial performance improvements,
> especially when factoring in SSL:
>
> 379 HTTP SSL requests
>
> Using HTTP/2 in serial: 63.293796062469 (HTTP/1.1 in serial should be even
> slower)
> Using HTTP/1.1 with curl_multi: 12.383034944534
> Using HTTP/2 w/multiplexing: 2.7933928966522

I think it should be fine as nothing is changed in the code but the
constants addition.

Let see what the RMs say :)

---

## #88034 — Pierre Joye — 2015-09-03T11:40:06+00:00

URL: https://externals.io/message/88000#88034

>
> Davey Shafik in php.internals (Wed, 2 Sep 2015 17:31:44 +1200):
> > […]
>
> I applied the same patch to the sources of the almost released 5.6.13.
> Patch OK (6 lines offset), but there is no HTTP2 entry in 5.6's phpinfo
> for cUrl. So it is not obvious that something has changed.
>
> Could you make a test for it?

It should be visible if curl supports it, under the protocol section

Did you build curl with nghttp2?

> --
> Jan

---

## #88050 — Kalle Sommer Nielsen — 2015-09-04T14:00:16+00:00

URL: https://externals.io/message/88000#88050 · In reply to: #88000

Hi Davey

2015-09-02 7:31 GMT+02:00 Davey Shafik <davey@php.net>:
> Hi,
>
> I've been poking around at HTTP/2 a lot lately, and it seems that so long
> as you are using libcurl 7.43.0+ it's possible to do request multiplexing.
>
> This change simply introduces three constants, `CURLPIPE_NOTHING` (0),
> CURLPIPE_HTTP1 (1), and `CURLPIPE_MULTIPLEX` (2) which represent possible
> values passed into `curl_multi_setopt()` for the `CURLMOPT_PIPELINING` option.
> Current behavior of passing in 0 and 1 map to the first two constants,
> while the third allows for multiplexing.
>
> Now, of course, being constants, you can just pass in 0, 1, or 2, but this
> brings the consistency and explicitness of exposing them as with all the
> other curl constants.
>
> I'd love to see this make it into PHP 7.0 if it's not too late? It's
> extremely trivial, but whatever — not that fussed :)
>
> PR is here: https://github.com/php/php-src/pull/1497

Me and Anatol have talked it over and we're fine with this coming into
RC3 as it beats having hardcoded values in the code or ugly hacks for
7.0.0 only, so go ahead and commit the PR.

Thanks for your work :)



-- 
regards,

Kalle Sommer Nielsen
kalle@php.net

---

## #88051 — Davey Shafik — 2015-09-04T14:47:24+00:00

URL: https://externals.io/message/88000#88051 · In reply to: #88050

> 
> 
> Hi Davey
> 
> 2015-09-02 7:31 GMT+02:00 Davey Shafik <davey@php.net>:
> > […]
> 
> Me and Anatol have talked it over and we're fine with this coming into
> RC3 as it beats having hardcoded values in the code or ugly hacks for
> 7.0.0 only, so go ahead and commit the PR.
> 
> Thanks for your work :)

Hey Kalle,

This is great... but I don't have karma to merge it I don't think? Be happy to be wrong :)

- Davey

---

## #88052 — Kalle Sommer Nielsen — 2015-09-04T14:52:17+00:00

URL: https://externals.io/message/88000#88052 · In reply to: #88051

Hi Davey

2015-09-04 16:47 GMT+02:00 Davey Shafik <me@daveyshafik.com>:
> Hey Kalle,
>
> This is great... but I don't have karma to merge it I don't think? Be happy to be wrong :)

Ah yes, I see you don't have php-src karma
(http://people.php.net/user.php?username=davey) I will make sure it
will be merged, unless you want the src karma and do it yourself :)


-- 
regards,

Kalle Sommer Nielsen
kalle@php.net
