From: Michael Wallner Date: Thu, 11 Dec 2008 14:23:59 +0000 (+0000) Subject: * Added request options: X-Git-Tag: RELEASE_1_7_0b1~11 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=c52642ccff4fe2887c9d5581816a7cae55766df4;p=m6w6%2Fext-http * Added request options: - postredir: enforcing RFC conformig POST after redirect (libcurl >= 7.17.1) - address_scope: RFC4007 zone_id (libcurl >= 7.19.0) - ssl->issuercert: validate peer certificate issuer (libcurl >= 7.19.0) - ssl->crlfile: require CRL check (libcurl >= 7.19.0 with openssl) - ssl->certinfo: enable the certinfo gatherer (libcurl >= 7.19.1 with openssl) * Added proxytype request option constants: - HTTP_PROXY_SOCKS4A - HTTP_PROXY_SOCKS5_HOSTNAME * Added request info members: - redirect_url (libcurl >= 7.18.2) - primary_ip (libcurl >= 7.19.0) - appconnect_time (libcurl >= 7.19.0) - certinfo (libcurl >= 7.19.1 with openssl) --- diff --git a/http_request_api.c b/http_request_api.c index ad7f88e..42ef30f 100644 --- a/http_request_api.c +++ b/http_request_api.c @@ -181,6 +181,10 @@ PHP_MINIT_FUNCTION(http_request) #if HTTP_CURL_VERSION(7,15,2) HTTP_LONG_CONSTANT("HTTP_PROXY_SOCKS4", CURLPROXY_SOCKS4); +#endif +#if HTTP_CURL_VERSION(7,18,0) + HTTP_LONG_CONSTANT("HTTP_PROXY_SOCKS4A", CURLPROXY_SOCKS4A); + HTTP_LONG_CONSTANT("HTTP_PROXY_SOCKS5_HOSTNAME", CURLPROXY_SOCKS5_HOSTNAME); #endif HTTP_LONG_CONSTANT("HTTP_PROXY_SOCKS5", CURLPROXY_SOCKS5); HTTP_LONG_CONSTANT("HTTP_PROXY_HTTP", CURLPROXY_HTTP); @@ -474,6 +478,11 @@ PHP_HTTP_API void _http_request_defaults(http_request *request) HTTP_CURL_OPT(CURLOPT_HTTP_TRANSFER_DECODING, 0L); #endif HTTP_CURL_OPT(CURLOPT_FOLLOWLOCATION, 0L); +#if HTTP_CURL_VERSION(7,19,1) + HTTP_CURL_OPT(CURLOPT_POSTREDIR, 0L); +#elif HTTP_CURL_VERSION(7,17,1) + HTTP_CURL_OPT(CURLOPT_POST301, 0L); +#endif HTTP_CURL_OPT(CURLOPT_UNRESTRICTED_AUTH, 0L); HTTP_CURL_OPT(CURLOPT_REFERER, NULL); HTTP_CURL_OPT(CURLOPT_USERAGENT, "PECL::HTTP/" PHP_HTTP_VERSION " (PHP/" PHP_VERSION ")"); @@ -500,6 +509,15 @@ PHP_HTTP_API void _http_request_defaults(http_request *request) HTTP_CURL_OPT(CURLOPT_SSL_VERIFYPEER, 0L); HTTP_CURL_OPT(CURLOPT_SSL_VERIFYHOST, 0L); HTTP_CURL_OPT(CURLOPT_SSL_CIPHER_LIST, NULL); +#if HTTP_CURL_VERSION(7,19,0) + HTTP_CURL_OPT(CURLOPT_ISSUERCERT, NULL); + #if defined(HTTP_HAVE_OPENSSL) + HTTP_CURL_OPT(CURLOPT_CRLFILE, NULL); + #endif +#endif +#if HTTP_CURL_VERSION(7,19,1) && defined(HTTP_HAVE_OPENSSL) + HTTP_CURL_OPT(CURLOPT_CERTINFO, NULL); +#endif #ifdef HTTP_CURL_CAINFO HTTP_CURL_OPT(CURLOPT_CAINFO, HTTP_CURL_CAINFO); #else @@ -661,6 +679,13 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti if ((zoption = http_request_option(request, options, "port", IS_LONG))) { HTTP_CURL_OPT(CURLOPT_PORT, Z_LVAL_P(zoption)); } + + /* RFC4007 zone_id */ +#if HTTP_CURL_VERSION(7,19,0) + if ((zoption = http_request_option(request, options, "address_scope", IS_LONG))) { + HTTP_CURL_OPT(CURLOPT_ADDRESS_SCOPE, Z_LVAL_P(zoption)); + } +#endif /* auth */ if ((zoption = http_request_option(request, options, "httpauth", IS_STRING)) && Z_STRLEN_P(zoption)) { @@ -677,6 +702,15 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti if ((zoption = http_request_option(request, options, "unrestrictedauth", IS_BOOL))) { HTTP_CURL_OPT(CURLOPT_UNRESTRICTED_AUTH, Z_LVAL_P(zoption)); } +#if HTTP_CURL_VERSION(7,17,1) + if ((zoption = http_request_option(request, options, "postredir", IS_BOOL))) { +# if HTTP_CURL_VERSION(7,19,1) + HTTP_CURL_OPT(CURLOPT_POSTREDIR, Z_BVAL_P(zoption) ? 1L : 0L); +# else + HTTP_CURL_OPT(CURLOPT_POST301, Z_BVAL_P(zoption) ? 1L : 0L); +# endif + } +#endif } /* retries, defaults to 0 */ @@ -922,6 +956,15 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti HTTP_CURL_OPT_STRING(CURLOPT_CAPATH, -3, 1); HTTP_CURL_OPT_STRING(CURLOPT_RANDOM_FILE, -3, 1); HTTP_CURL_OPT_STRING(CURLOPT_EGDSOCKET, -3, 1); +#if HTTP_CURL_VERSION(7,19,0) + HTTP_CURL_OPT_STRING(CURLOPT_ISSUERCERT, -3, 1); + #if defined(HTTP_HAVE_OPENSSL) + HTTP_CURL_OPT_STRING(CURLOPT_CRLFILE, -3, 1); + #endif +#endif +#if HTTP_CURL_VERSION(7,19,1) && defined(HTTP_HAVE_OPENSSL) + HTTP_CURL_OPT_LONG(CURLOPT_CERTINFO, -3); +#endif } } } diff --git a/http_request_info.c b/http_request_info.c index 1d12f36..db72fac 100644 --- a/http_request_info.c +++ b/http_request_info.c @@ -124,6 +124,32 @@ PHP_HTTP_API void _http_request_info(http_request *request, HashTable *info) curl_slist_free_all(s); } #endif +#if HTTP_CURL_VERSION(7,18,2) + if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_REDIRECT_URL, &c)) { + add_assoc_string_ex(&array, "redirect_url", sizeof("redirect_url"), c ? c : "", 1); + } +#endif +#if HTTP_CURL_VERSION(7,19,0) + if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_PRIMARY_IP, &c)) { + add_assoc_string_ex(&array, "primary_ip", sizeof("primary_ip"), c ? c : "", 1); + } +#endif +#if HTTP_CURL_VERSION(7,19,0) + if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_APPCONNECT_TIME, &d)) { + add_assoc_double_ex(&array, "appconnect_time", sizeof("appconnect_time"), d); + } +#endif +#if HTTP_CURL_VERSION(7,19,1) && defined(HTTP_HAVE_OPENSSL) + if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_CERTINFO, &s)) { + MAKE_STD_ZVAL(subarray); + array_init(subarray); + for (p = s; p; p = p->next) { + add_next_index_string(subarray, p->data, 1); + } + add_assoc_zval_ex(&array, "certinfo", sizeof("certinfo"), subarray); + curl_slist_free_all(s); + } +#endif /* END */ add_assoc_string_ex(&array, "error", sizeof("error"), http_request_storage_get(request->ch)->errorbuffer, 1); } diff --git a/package2.xml b/package2.xml index 34d1096..bb6035d 100644 --- a/package2.xml +++ b/package2.xml @@ -40,6 +40,20 @@ support. Parallel requests are available for PHP 5 and greater. BSD, revised = 7.17.1) + - address_scope: RFC4007 zone_id (libcurl >= 7.19.0) + - ssl->issuercert: validate peer certificate issuer (libcurl >= 7.19.0) + - ssl->crlfile: require CRL check (libcurl >= 7.19.0 with openssl) + - ssl->certinfo: enable the certinfo gatherer (libcurl >= 7.19.1 with openssl) +* Added proxytype request option constants: + - HTTP_PROXY_SOCKS4A + - HTTP_PROXY_SOCKS5_HOSTNAME +* Added request info members: + - redirect_url (libcurl >= 7.18.2) + - primary_ip (libcurl >= 7.19.0) + - appconnect_time (libcurl >= 7.19.0) + - certinfo (libcurl >= 7.19.1 with openssl) ]]> diff --git a/scripts/gen_curlinfo.php b/scripts/gen_curlinfo.php index f7c6cdb..54137ba 100644 --- a/scripts/gen_curlinfo.php +++ b/scripts/gen_curlinfo.php @@ -32,7 +32,11 @@ function file_re($file, $pattern, $all = true) { } $ifdefs = array( - 'COOKIELIST' => '7,14,1' + 'COOKIELIST' => 'HTTP_CURL_VERSION(7,14,1)', + 'PRIMARY_IP' => 'HTTP_CURL_VERSION(7,19,0)', + 'APPCONNECT_TIME' => 'HTTP_CURL_VERSION(7,19,0)', + 'REDIRECT_URL' => 'HTTP_CURL_VERSION(7,18,2)', + 'CERTINFO' => 'HTTP_CURL_VERSION(7,19,1) && defined(HTTP_HAVE_OPENSSL)' ); $exclude = array( 'PRIVATE', 'LASTSOCKET', 'FTP_ENTRY_PATH' @@ -77,7 +81,7 @@ ob_start(); foreach ($infos as $info) { list(, $full, $short, $type) = $info; if (in_array($short, $exclude)) continue; - if (isset($ifdefs[$short])) printf("#if HTTP_CURL_VERSION(%s)\n", $ifdefs[$short]); + if (isset($ifdefs[$short])) printf("#if %s\n", $ifdefs[$short]); printf($templates[$type], $full, strtolower((isset($translate[$short])) ? $translate[$short] : $short)); if (isset($ifdefs[$short])) printf("#endif\n"); }