Edit report at https://bugs.php.net/bug.php?id=62906&edit=1
ID: 62906
Comment by: niki at gorchilov dot com
Reported by: niki at gorchilov dot com
Summary: [feature request] add support for CURLOPT_*SOCK*
options
Status: Assigned
Type: Feature/Change Request
Package: cURL related
Operating System: All
PHP Version: Irrelevant
Assigned To: pierrick
Block user comment: N
Private report: N
New Comment:
Looked at PHP sources to find how the similar CURLOPT_HEADERFUNCTION has been
implemented and here's my understanding:
- ext/curl/interface.c is the only file that needs modification
- Seems CURLOPT_SOCKOPTDATA, CURLOPT_OPENSOCKETDATA, CURLOPT_CLOSESOCKETDATA
cannot be exported to the end user, as PHP will need it internally to pass a
context to the callback function. No a big deal IMHO.
- remaining three options - CURLOPT_SOCKOPTFUNCTION,
CURLOPT_OPENSOCKETFUNCTION,
CURLOPT_CLOSESOCKETFUNCTION shall be added in PHP_MINIT_FUNCTION,
_php_curl_set_default_options and _php_curl_setopt.
- all the three callbacks shall be implemented using curl_write_header as a
model.
Hope this helps.
Previous Comments:
------------------------------------------------------------------------
[2012-08-24 02:32:41] [email protected]
what do you think? maybe expose some new constants?
------------------------------------------------------------------------
[2012-08-23 15:02:25] niki at gorchilov dot com
Description:
------------
libcurl has 6 callback options that are missing in PHP bindings, but give the
user
great control over the underlying socket:
- CURLOPT_SOCKOPTFUNCTION
- CURLOPT_SOCKOPTDATA
- CURLOPT_OPENSOCKETFUNCTION
- CURLOPT_OPENSOCKETDATA
- CURLOPT_CLOSESOCKETFUNCTION
- CURLOPT_CLOSESOCKETDATA
Without support for these options, developers can't set socket bindings,
options
and marks on connections done via cURL.
That is a great limitation for serious network applications written in PHP.
Here's
one real example:
http://stackoverflow.com/questions/12080550/tproxy-with-libcurl-or-http-streams-
under-php
Full description of these options is available at:
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTSOCKOPTFUNCTION
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62906&edit=1