- Fixed build on php-trunk
[m6w6/ext-http] / http_request_info.c
index 1d12f36d397f0e26ee05f2c0dbd44f310c251844..809512ade05d1ed6510a4f66679513b38c94fc37 100644 (file)
@@ -6,7 +6,7 @@
     | modification, are permitted provided that the conditions mentioned |
     | in the accompanying LICENSE file are met.                          |
     +--------------------------------------------------------------------+
     | modification, are permitted provided that the conditions mentioned |
     | in the accompanying LICENSE file are met.                          |
     +--------------------------------------------------------------------+
-    | Copyright (c) 2004-2007, Michael Wallner <mike@php.net>            |
+    | Copyright (c) 2004-2010, Michael Wallner <mike@php.net>            |
     +--------------------------------------------------------------------+
 */
 
     +--------------------------------------------------------------------+
 */
 
@@ -108,7 +108,9 @@ PHP_HTTP_API void _http_request_info(http_request *request, HashTable *info)
                MAKE_STD_ZVAL(subarray);
                array_init(subarray);
                for (p = s; p; p = p->next) {
                MAKE_STD_ZVAL(subarray);
                array_init(subarray);
                for (p = s; p; p = p->next) {
-                       add_next_index_string(subarray, p->data, 1);
+                       if (p->data) {
+                               add_next_index_string(subarray, p->data, 1);
+                       }
                }
                add_assoc_zval_ex(&array, "ssl_engines", sizeof("ssl_engines"), subarray);
                curl_slist_free_all(s);
                }
                add_assoc_zval_ex(&array, "ssl_engines", sizeof("ssl_engines"), subarray);
                curl_slist_free_all(s);
@@ -118,13 +120,68 @@ PHP_HTTP_API void _http_request_info(http_request *request, HashTable *info)
                MAKE_STD_ZVAL(subarray);
                array_init(subarray);
                for (p = s; p; p = p->next) {
                MAKE_STD_ZVAL(subarray);
                array_init(subarray);
                for (p = s; p; p = p->next) {
-                       add_next_index_string(subarray, p->data, 1);
+                       if (p->data) {
+                               add_next_index_string(subarray, p->data, 1);
+                       }
                }
                add_assoc_zval_ex(&array, "cookies", sizeof("cookies"), subarray);
                curl_slist_free_all(s);
        }
 #endif
                }
                add_assoc_zval_ex(&array, "cookies", sizeof("cookies"), subarray);
                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,4)
+       if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_CONDITION_UNMET, &l)) {
+               add_assoc_long_ex(&array, "condition_unmet", sizeof("condition_unmet"), l);
+       }
+#endif
 /* END */
 /* END */
+#if HTTP_CURL_VERSION(7,19,1) && defined(HTTP_HAVE_OPENSSL)
+       {
+               int i;
+               zval *ci_array;
+               struct curl_certinfo *ci;
+               char *colon, *keyname;
+               
+               if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_CERTINFO, &ci)) {
+                       MAKE_STD_ZVAL(ci_array);
+                       array_init(ci_array);
+                       
+                       for (i = 0; i < ci->num_of_certs; ++i) {
+                               s = ci->certinfo[i];
+                               
+                               MAKE_STD_ZVAL(subarray);
+                               array_init(subarray);
+                               for (p = s; p; p = p->next) {
+                                       if (p->data) {
+                                               if ((colon = strchr(p->data, ':'))) {
+                                                       keyname = estrndup(p->data, colon - p->data);
+                                                       add_assoc_string_ex(subarray, keyname, colon - p->data + 1, colon + 1, 1);
+                                                       efree(keyname);
+                                               } else {
+                                                       add_next_index_string(subarray, p->data, 1);
+                                               }
+                                       }
+                               }
+                               add_next_index_zval(ci_array, subarray);
+                       }
+                       add_assoc_zval_ex(&array, "certinfo", sizeof("certinfo"), ci_array);
+               }
+       }
+#endif
        add_assoc_string_ex(&array, "error", sizeof("error"), http_request_storage_get(request->ch)->errorbuffer, 1);
 }
 /* }}} */
        add_assoc_string_ex(&array, "error", sizeof("error"), http_request_storage_get(request->ch)->errorbuffer, 1);
 }
 /* }}} */