Hey all,
I'm trying to work up a patch for ext/perl to allow the
CURLMOPT_PUSHFUNCTION and CURLMOPT_PUSHDATA options, which allow for HTTP/2
Server Push.
PUSHFUNCTION allow you to register a callback that can accept/reject an
HTTP/2 server push by returning either CURL_PUSH_OK (0), or CURL_PUSH_DENY
(1)
PUSHDATA allows you to pass in a pointer that is passed straight into the
callback untouched.
So, I'm wondering a few things:
- Should it be possible to register multiple callbacks, if so we'd need
something like CURL_PUSH_PASSTHRU or some such to indicate it should move
to the next callback in the chain. This obviously differs from the libcurl
behavior, perhaps something to bring back to libcurl though? It would allow
different callbacks for say, different content types (if that's available
in the request, not sure yet :P)
1.1) If we allow multiples, do we allow removing them, what does that API
look like?
- For PUSHDATA would we pass through a referenced user land variable? or
do we just ignore this feature?
My thinking on implementation was to have curl_multi_setopt store the
callback[s] (not sure where?), and have a fixed _php_curl_pushfunction
function that would be registered as the callback for libcurl, and would
just pass it's arguments through to the callback[s].
The issue with this is that I need to figure out stuff like the push
headers being passed through. There are two functions
curl_pushheader_bynum() and curl_pushheader_byname() which are meant to be
used to access the struct that contains the headers, so I figured I can
expose those two functions in user land, and I guess make the headers a
resource that is passed into the callback?
The alternative seems to be to resolve that in the extension and pass
through an array or something?
I'd rather not be creating new resources, but ext/curl obviously has a
precedence of using them, so it would fit the UX.
Any thoughts? I'd love to get this into PHP 7.1 (or before, if possible!).
Thanks,
- Davey