- add portrange request option
authorMichael Wallner <mike@php.net>
Fri, 17 Feb 2006 16:35:05 +0000 (16:35 +0000)
committerMichael Wallner <mike@php.net>
Fri, 17 Feb 2006 16:35:05 +0000 (16:35 +0000)
docs/functions.html
http_functions.c
http_request_api.c
package2.xml
php_http.h

index cca7dc41edede005dd153b669d52b5582f6011ca..7871ba15e6b549625a47cdd7b3f432de50b66448 100644 (file)
@@ -326,6 +326,7 @@ array where the following keys will be recognized:</p><pre> - redirect:
  - encodecookies:    bool, whether to urlencode the cookies (default: true)<br />
  - resetcookies:     bool, wheter to reset the cookies<br />
  - cookiestore:      string, path to a file where cookies are/will be stored<br />
+ - cookiesession:    bool, accept (true) or reset (false) sessioncookies<br />
  - resume:           int, byte offset to start the download from;<br />
                      if the server supports ranges<br />
  - maxfilesize:      int, maximum file size that should be downloaded;<br />
@@ -335,6 +336,8 @@ array where the following keys will be recognized:</p><pre> - redirect:
  - timeout:          int, seconds the request may take<br />
  - connecttimeout:   int, seconds the connect may take<br />
  - onprogress:       mixed, progress callback<br />
+ - interface:        string, outgoing network interface (ifname, ip or hostname)<br />
+ - portrange:        array, 2 integers specifying outgoing portrange to try<br />
  - ssl:              array, with the following options:<br />
                      cert:        string, path to certificate<br />
                      certtype:    string, type of certificate<br />
@@ -1355,7 +1358,7 @@ http.cache_log is set.</p>
 </li>
 </ul>
 </div>
-    <p><b>Generated at: Wed, 15 Feb 2006 08:40:01 +0100</b></p>
+    <p><b>Generated at: Fri, 17 Feb 2006 17:34:44 +0100</b></p>
 </body>
 </html>
 
index 8a5e49ed5f260bef1087dece1562edb39784703d..1c63ba0d6b270f57dbe2a01a28d012e44b98fb59 100644 (file)
@@ -1246,6 +1246,7 @@ PHP_FUNCTION(http_match_request_header)
  *  - encodecookies:    bool, whether to urlencode the cookies (default: true)
  *  - resetcookies:     bool, wheter to reset the cookies
  *  - cookiestore:      string, path to a file where cookies are/will be stored
+ *  - cookiesession:    bool, accept (true) or reset (false) sessioncookies
  *  - resume:           int, byte offset to start the download from;
  *                      if the server supports ranges
  *  - maxfilesize:      int, maximum file size that should be downloaded;
@@ -1255,6 +1256,8 @@ PHP_FUNCTION(http_match_request_header)
  *  - timeout:          int, seconds the request may take
  *  - connecttimeout:   int, seconds the connect may take
  *  - onprogress:       mixed, progress callback
+ *  - interface:        string, outgoing network interface (ifname, ip or hostname)
+ *  - portrange:        array, 2 integers specifying outgoing portrange to try
  *  - ssl:              array, with the following options:
  *                      cert:        string, path to certificate
  *                      certtype:    string, type of certificate
index 613c32a8820ee2f82780e378aef80ec1a4f9878c..e34b866330acc551cb4dccc08b36eef94f40616a 100644 (file)
@@ -429,6 +429,10 @@ PHP_HTTP_API void _http_request_defaults(http_request *request)
                HTTP_CURL_OPT(CURLOPT_PROXYAUTH, 0);
                HTTP_CURL_OPT(CURLOPT_INTERFACE, NULL);
                HTTP_CURL_OPT(CURLOPT_PORT, 0);
+#if HTTP_CURL_VERSION(7,15,2)
+               HTTP_CURL_OPT(CURLOPT_LOCALPORT, 0);
+               HTTP_CURL_OPT(CURLOPT_LOCALPORTRANGE, 0);
+#endif
                HTTP_CURL_OPT(CURLOPT_USERPWD, NULL);
                HTTP_CURL_OPT(CURLOPT_HTTPAUTH, 0);
                HTTP_CURL_OPT(CURLOPT_ENCODING, NULL);
@@ -438,7 +442,7 @@ PHP_HTTP_API void _http_request_defaults(http_request *request)
                HTTP_CURL_OPT(CURLOPT_USERAGENT, "PECL::HTTP/" PHP_EXT_HTTP_VERSION " (PHP/" PHP_VERSION ")");
                HTTP_CURL_OPT(CURLOPT_HTTPHEADER, NULL);
                HTTP_CURL_OPT(CURLOPT_COOKIE, NULL);
-#if LIBCURL_VERSION_NUM >= 0x070e01
+#if HTTP_CURL_VERSION(7,14,1)
                HTTP_CURL_OPT(CURLOPT_COOKIELIST, NULL);
 #endif
                HTTP_CURL_OPT(CURLOPT_COOKIEFILE, NULL);
@@ -540,6 +544,27 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti
        /* outgoing interface */
        if ((zoption = http_request_option(request, options, "interface", IS_STRING))) {
                HTTP_CURL_OPT(CURLOPT_INTERFACE, Z_STRVAL_P(zoption));
+               
+#if HTTP_CURL_VERSION(7,15,2)
+               if ((zoption = http_request_option(request, options, "portrange", IS_ARRAY))) {
+                       zval *prs, *pre;
+                       
+                       zend_hash_internal_pointer_reset(Z_ARRVAL_P(zoption));
+                       if (SUCCESS == zend_hash_get_current_data(Z_ARRVAL_P(zoption), (void **) &prs)) {
+                               zend_hash_move_forward(Z_ARRVAL_P(zoption));
+                               if (SUCCESS == zend_hash_get_current_data(Z_ARRVAL_P(zoption), (void **) &pre)) {
+                                       zval *prs_cpy = zval_copy(IS_LONG, *prs), *pre_cpy = zval_copy(IS_LONG, *pre);
+                                       
+                                       if (Z_LVAL_P(prs_cpy) && Z_LVAL_P(pre_cpy)) {
+                                               HTTP_CURL_OPT(CURLOPT_LOCALPORT, MIN(Z_LVAL_P(prs_cpy), Z_LVAL_P(pre_cpy)));
+                                               HTTP_CURL_OPT(CURLOPT_LOCALPORTRANGE, ABS(Z_LVAL_P(prs_cpy)-Z_LVAL_P(pre_cpy))+1L);
+                                       }
+                                       zval_free(&prs_cpy);
+                                       zval_free(&pre_cpy);
+                               }
+                       }
+               }
+#endif
        }
 
        /* another port */
@@ -660,7 +685,6 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti
                                }
                        } else {
                                HashPosition pos;
-                               zval *cookie_val = NULL;
                                char *cookie_key = NULL;
                                ulong cookie_idx;
                                
@@ -686,7 +710,7 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti
                }
        }
 
-#if LIBCURL_VERSION_NUM >= 0x070e01
+#if HTTP_CURL_VERSION(7,14,1)
        /* reset cookies */
        if ((zoption = http_request_option(request, options, "resetcookies", IS_BOOL)) && Z_LVAL_P(zoption)) {
                HTTP_CURL_OPT(CURLOPT_COOKIELIST, "ALL");
@@ -873,7 +897,7 @@ PHP_HTTP_API void _http_request_info(http_request *request, HashTable *info)
        HTTP_CURL_INFO(CURLINFO_HTTPAUTH_AVAIL);
        HTTP_CURL_INFO(CURLINFO_PROXYAUTH_AVAIL);
        HTTP_CURL_INFO(CURLINFO_NUM_CONNECTS);
-#if LIBCURL_VERSION_NUM >= 0x070e01
+#if HTTP_CURL_VERSION(7,14,1)
        HTTP_CURL_INFO_EX(CURLINFO_COOKIELIST, "cookies");
 #endif
        HTTP_CURL_INFO(CURLINFO_OS_ERRNO);
index 930391a52d4d2ffd0473158cbe30af9d58206fc3..c3aa0390cbe239e8ffac4a7c0d6247084e6a849b 100644 (file)
@@ -47,6 +47,7 @@ HttpResponse
  <license>BSD, revised</license>
  <notes><![CDATA[
 + Added If-Range header recognition.
++ Added "portrange" request option.
 
 * Fixed bug #6804 - configure does not recognize --without-http-zlib-compression.
 * Fixed cases where 412 Precondition failed should be sent.
index 4b5aaa557fffa24f9965d2ff86f79f4a6b55e146..213384f0630f154beeda9a983038bf6e9ba05ed9 100644 (file)
@@ -59,6 +59,7 @@
 #              define CURL_STATICLIB
 #      endif
 #      include <curl/curl.h>
+#      define HTTP_CURL_VERSION(x, y, z) (LIBCURL_VERSION_NUM >= (((x)<<16) + ((y)<<8) + (z)))
 #endif
 
 #if defined(HTTP_WANT_MAGIC) && defined(HTTP_HAVE_MAGIC)