# [RFC] HTTP/2 Server Push support in ext/curl

- Thread: https://externals.io/message/89275
- Original archive: https://news-web.php.net/php.internals/89275
- Started by Davey Shafik on 2015-11-18T22:31:23+00:00
- Messages: 5
- RFC: Add HTTP/2 Server Push support to ext/curl (Implemented (PHP 7.1)) — https://externals.io/rfc/curl_http2_push.md
- 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

---

## #89275 — Davey Shafik — 2015-11-18T22:31:23+00:00

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

Hey folks,

I'd like to introduce a new RFC for 7.1 that will add support for HTTP/2
Server Push to ext/curl.

This is exposing new features from libcurl to user land, which means they
must have the latest (in fact currently unreleased, due to a bugfix)
version of libcurl.

For those who are not aware, HTTP/2 support is growing rapidly, and is
already available in 60% of browsers, Apache 2 (via mod_h2), nginx, and
even IIS.

The RFC can be seen here: https://wiki.php.net/rfc/curl_http2_push
With the patch at:
https://github.com/php/php-src/compare/master...dshafik:curl-http2-push

The patch still needs some work, possibly a lot of work due to my
inexperience with C. Specifically, there are some memory leaks I've managed
to introduce with the headers array stuff (I'm pretty sure, lines
529-535[1]) and there is some duplicated code from interface.c (lines
454-523[2]) that I was unable to refactor out successfully to it's own
function. Plus, on the whole it seems incredibly untidy to me.

Feedback welcome!

- Davey

[1]
https://github.com/php/php-src/compare/master...dshafik:curl-http2-push#diff-ab7a9164033bd55887d45d0a6cb837eeR529
[2]
https://github.com/php/php-src/compare/master...dshafik:curl-http2-push#diff-ab7a9164033bd55887d45d0a6cb837eeR451

---

## #89276 — Davey Shafik — 2015-11-18T23:34:57+00:00

URL: https://externals.io/message/89275#89276 · In reply to: #89275

Forgot to mention, if you'd like to try this patch for yourself, check out
my Docker container stuff here (with instructions :):
https://github.com/dshafik/php-http2-push-example



> Hey folks,
>
> I'd like to introduce a new RFC for 7.1 that will add support for HTTP/2
> Server Push to ext/curl.
>
> This is exposing new features from libcurl to user land, which means they
> must have the latest (in fact currently unreleased, due to a bugfix)
> version of libcurl.
>
> For those who are not aware, HTTP/2 support is growing rapidly, and is
> already available in 60% of browsers, Apache 2 (via mod_h2), nginx, and
> even IIS.
>
> The RFC can be seen here: https://wiki.php.net/rfc/curl_http2_push
> With the patch at:
> https://github.com/php/php-src/compare/master...dshafik:curl-http2-push
>
> The patch still needs some work, possibly a lot of work due to my
> inexperience with C. Specifically, there are some memory leaks I've managed
> to introduce with the headers array stuff (I'm pretty sure, lines
> 529-535[1]) and there is some duplicated code from interface.c (lines
> 454-523[2]) that I was unable to refactor out successfully to it's own
> function. Plus, on the whole it seems incredibly untidy to me.
>
> Feedback welcome!
>
> - Davey
>
> [1]
> https://github.com/php/php-src/compare/master...dshafik:curl-http2-push#diff-ab7a9164033bd55887d45d0a6cb837eeR529
> [2]
> https://github.com/php/php-src/compare/master...dshafik:curl-http2-push#diff-ab7a9164033bd55887d45d0a6cb837eeR451

---

## #89294 — Davey Shafik — 2015-11-22T17:14:56+00:00

URL: https://externals.io/message/89275#89294 · In reply to: #89276

> Forgot to mention, if you'd like to try this patch for yourself, check out
> my Docker container stuff here (with instructions :):
> https://github.com/dshafik/php-http2-push-example
>
> 
>
> > […]
>
>
I have made some further changes to this patch (tidied it up a bit, and
refactored out the duplicate code) and RFC (no longer passing in the number
of headers, this was a holdover from the C API and unnecessary in PHP, just
use `count()` on the header array).

If you tried out the Docker container, a simple rebuild (perhaps with
--no-cache) will fetch the latest patch and rebuild.

The memory leaks are still there, and I'm not much closer to plugging them
— again, any help would be appreciated.

Thanks,

---

## #89517 — Davey Shafik — 2015-12-01T20:42:40+00:00

URL: https://externals.io/message/89275#89517 · In reply to: #89294

Hi all,

I wanted to give another update, thanks to the input of Sean DuBois, the
patch is now pretty much final. There is one more memory leak, but I
believe it's in libcurl itself, I'll follow up over there on that.

Sara expressed a desire to get this into HHVM, so I'm going to follow up
with her specifically to get an opinion on the implementation.

Assuming she has no issues, I'd like to talk about moving forward with a
vote soon.



> 
>
> > […]
> I have made some further changes to this patch (tidied it up a bit, and
> refactored out the duplicate code) and RFC (no longer passing in the number
> of headers, this was a holdover from the C API and unnecessary in PHP, just
> use `count()` on the header array).
>
> If you tried out the Docker container, a simple rebuild (perhaps with
> --no-cache) will fetch the latest patch and rebuild.
>
> The memory leaks are still there, and I'm not much closer to plugging them
> — again, any help would be appreciated.
>
> Thanks,

---

## #89528 — Sara Golemon — 2015-12-02T23:36:53+00:00

URL: https://externals.io/message/89275#89528 · In reply to: #89517

> I wanted to give another update, thanks to the input of Sean DuBois, the
> patch is now pretty much final. There is one more memory leak, but I
> believe it's in libcurl itself, I'll follow up over there on that.
>
> Sara expressed a desire to get this into HHVM, so I'm going to follow up
> with her specifically to get an opinion on the implementation.
>
> Assuming she has no issues, I'd like to talk about moving forward with a
> vote soon.
>
LGTM; I'll wait until it's landed before getting started on the HHVM
port since it needs a bleeding edge version of libcurl anyway.

-Sara
