rfc:curl_http2_push
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:curl_http2_push [2015/11/12 23:25] – davey | rfc:curl_http2_push [2015/11/22 05:29] – davey | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2015-10-01 | * Date: 2015-10-01 | ||
* Author: Davey Shafik, davey@php.net | * Author: Davey Shafik, davey@php.net | ||
- | * Status: | + | * Status: |
* First Published at: https:// | * First Published at: https:// | ||
Line 12: | Line 12: | ||
Server push allows the server to push additional resources relevant to the requested resource directly to the client proactively. | Server push allows the server to push additional resources relevant to the requested resource directly to the client proactively. | ||
- | Server push is available in libcurl since 7.44.0. | + | Server push is available in libcurl since 7.44.0, but broken till the as-yet-unreleased 7.46.0 (See: [[https:// |
===== Libcurl Implementation ===== | ===== Libcurl Implementation ===== | ||
Line 28: | Line 28: | ||
<code php> | <code php> | ||
<?php | <?php | ||
- | $callable | + | $transfers = 1; |
- | { | + | |
- | if ($header_count > 0 && curl_pushheader_byname(" | + | $callback |
- | | + | $transfers++; |
- | } | + | return |
- | return CURL_PUSH_OK; | + | }; |
- | } | + | |
$mh = curl_multi_init(); | $mh = curl_multi_init(); | ||
- | $user_data = null; | ||
- | curl_multi_setopt($mh, | + | curl_multi_setopt($mh, |
- | curl_multi_setopt($mh, | + | curl_multi_setopt($mh, |
- | ?> | + | |
+ | $ch = curl_init(); | ||
+ | curl_setopt($ch, | ||
+ | curl_setopt($ch, CURLOPT_HTTP_VERSION, | ||
+ | curl_setopt($ch, | ||
+ | |||
+ | // Debugging/ | ||
+ | // | ||
+ | curl_setopt($ch, | ||
+ | curl_setopt($ch, | ||
+ | |||
+ | curl_multi_add_handle($mh, | ||
+ | |||
+ | $active = null; | ||
+ | do { | ||
+ | | ||
+ | |||
+ | do { | ||
+ | $info = curl_multi_info_read($mh); | ||
+ | if (false !== $info && $info[' | ||
+ | $handle = $info[' | ||
+ | if ($handle !== null) { | ||
+ | $transfers--; | ||
+ | $out = curl_multi_getcontent($info[' | ||
+ | curl_multi_remove_handle($mh, | ||
+ | curl_close($handle); | ||
+ | } | ||
+ | } | ||
+ | } while ($info); | ||
+ | } while ($transfers); | ||
+ | |||
+ | curl_multi_close($mh); | ||
</ | </ | ||
===== Implementation ===== | ===== Implementation ===== | ||
- | Within [[https:// | + | Within [[https:// |
- | The user can also register a referenced variable ('' | + | We do not support |
- | We also have to handle | + | libcurl exposes |
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | No breaks, except possibly the referenced value for '' | + | No breaks |
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
Line 77: | Line 106: | ||
* '' | * '' | ||
- | * '' | ||
* '' | * '' | ||
* '' | * '' | ||
Line 89: | Line 117: | ||
===== Open Issues ===== | ===== Open Issues ===== | ||
- | - Adding a new resource isn't desirable but fits the current ext/curl API | + | Some memory leaks |
===== Future Scope ===== | ===== Future Scope ===== | ||
Line 102: | Line 130: | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
- | Patch is currently being worked on [[https:// | + | - (rough) Working patch can be found [[https:// |
+ | - Docker container for easy testing can be found [[http:// | ||
===== Implementation ===== | ===== Implementation ===== |
rfc/curl_http2_push.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1