]> granicus.if.org Git - php/commitdiff
- add CURLINFO_REDIRECT_URL
authorPierre Joye <pajoye@php.net>
Fri, 1 Apr 2011 17:19:08 +0000 (17:19 +0000)
committerPierre Joye <pajoye@php.net>
Fri, 1 Apr 2011 17:19:08 +0000 (17:19 +0000)
NEWS
ext/curl/interface.c

diff --git a/NEWS b/NEWS
index d233f084423beca08fba8075f609670040abae81..463e765cd50fdbf7b6987e5cd8fddbd7528650e8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,8 @@ PHP                                                                        NEWS
     (tomas dot brastavicius at quantum dot lt, Pierrick)
    . Fixed bug #48465 (sys_get_temp_dir() possibly inconsistent when using 
      TMPDIR on Windows). (Pierre)
+- cURL
+  . Added CURLINFO_REDIRECT_URL support. (Daniel Stenberg, Pierre)
 
 - DateTime extension:
   . Fixed bug #54340 (DateTime::add() method bug). (Adam)
index 092ab27a41ad997e8037fddaf30f19cc7d0cde74..77f72c18027156defe83c9ddc3f5dfc6ff638000 100644 (file)
@@ -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
@@ -2305,6 +2328,11 @@ PHP_FUNCTION(curl_getinfo)
                        create_certinfo(ci, listcode TSRMLS_CC);
                        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) {