summaryrefslogtreecommitdiff
path: root/ext/curl/interface.c
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2011-04-01 17:19:08 +0000
committerPierre Joye <pajoye@php.net>2011-04-01 17:19:08 +0000
commit689268a0ba4259c8f199cae6343b3d17cab9b6a5 (patch)
tree290c1a47b1fb364af44db926da750c060c0fd53d /ext/curl/interface.c
parent88c1755a14a8a8750686f5a1a0984ac35abdd8af (diff)
downloadphp-git-689268a0ba4259c8f199cae6343b3d17cab9b6a5.tar.gz
- add CURLINFO_REDIRECT_URL
Diffstat (limited to 'ext/curl/interface.c')
-rw-r--r--ext/curl/interface.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 092ab27a41..77f72c1802 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -331,6 +331,13 @@ zend_module_entry curl_module_entry = {
ZEND_GET_MODULE (curl)
#endif
+/* {{{ PHP_INI_BEGIN */
+PHP_INI_BEGIN()
+ PHP_INI_ENTRY("curl.cainfo", "", PHP_INI_SYSTEM, NULL)
+PHP_INI_END()
+/* }}} */
+
+/* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(curl)
@@ -458,6 +465,8 @@ PHP_MINIT_FUNCTION(curl)
le_curl = zend_register_list_destructors_ex(_php_curl_close, NULL, "curl", module_number);
le_curl_multi_handle = zend_register_list_destructors_ex(_php_curl_multi_close, NULL, "curl_multi", module_number);
+ REGISTER_INI_ENTRIES();
+
/* See http://curl.haxx.se/lxr/source/docs/libcurl/symbols-in-versions
or curl src/docs/libcurl/symbols-in-versions for a (almost) complete list
of options and which version they were introduced */
@@ -632,6 +641,10 @@ PHP_MINIT_FUNCTION(curl)
#if LIBCURL_VERSION_NUM > 0x071301
REGISTER_CURL_CONSTANT(CURLINFO_CERTINFO);
#endif
+#if LIBCURL_VERSION_NUM >= 0x071202
+ REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_URL);
+#endif
+
/* cURL protocol constants (curl_version) */
REGISTER_CURL_CONSTANT(CURL_VERSION_IPV6);
@@ -879,6 +892,7 @@ PHP_MSHUTDOWN_FUNCTION(curl)
php_curl_openssl_tsl = NULL;
}
#endif
+ UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
/* }}} */
@@ -1427,6 +1441,7 @@ PHP_FUNCTION(curl_init)
zval *clone;
char *url = NULL;
int url_len = 0;
+ char *cainfo;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &url, &url_len) == FAILURE) {
return;
@@ -1453,6 +1468,8 @@ PHP_FUNCTION(curl_init)
MAKE_STD_ZVAL(clone);
ch->clone = clone;
+
+
curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1);
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0);
curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str);
@@ -1465,6 +1482,12 @@ PHP_FUNCTION(curl_init)
curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1);
curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120);
curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */
+
+ cainfo = INI_STR("curl.cainfo");
+ if (cainfo && strlen(cainfo) > 0) {
+ curl_easy_setopt(ch->cp, CURLOPT_CAINFO, cainfo);
+ }
+
#if defined(ZTS)
curl_easy_setopt(ch->cp, CURLOPT_NOSIGNAL, 1);
#endif
@@ -2306,6 +2329,11 @@ PHP_FUNCTION(curl_getinfo)
CAAZ("certinfo", listcode);
}
#endif
+#if LIBCURL_VERSION_NUM >= 0x071202
+ if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_URL, &s_code) == CURLE_OK) {
+ CAAS("redirect_url", s_code);
+ }
+#endif
if (ch->header.str_len > 0) {
CAAS("request_header", ch->header.str);
}
@@ -2313,7 +2341,11 @@ PHP_FUNCTION(curl_getinfo)
switch (option) {
case CURLINFO_PRIVATE:
case CURLINFO_EFFECTIVE_URL:
- case CURLINFO_CONTENT_TYPE: {
+ case CURLINFO_CONTENT_TYPE:
+#if LIBCURL_VERSION_NUM >= 0x071202
+ case CURLINFO_REDIRECT_URL:
+#endif
+ {
char *s_code = NULL;
if (curl_easy_getinfo(ch->cp, option, &s_code) == CURLE_OK && s_code) {