fix access og HttpMessage properties
[m6w6/ext-http] / http_request_api.c
index 1d1252a0988399b783dd28089ec9f847246f4990..d32404ad729851a03bdc58b5bcfd95bc885b17ff 100644 (file)
@@ -6,7 +6,7 @@
     | 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>            |
     +--------------------------------------------------------------------+
 */
 
@@ -478,8 +478,10 @@ PHP_HTTP_API void _http_request_defaults(http_request *request)
                HTTP_CURL_OPT(CURLOPT_PROXYPORT, 0L);
                HTTP_CURL_OPT(CURLOPT_PROXYTYPE, 0L);
                /* libcurl < 7.19.6 does not clear auth info with USERPWD set to NULL */
+#if HTTP_CURL_VERSION(7,19,1)          
                HTTP_CURL_OPT(CURLOPT_PROXYUSERNAME, NULL);
                HTTP_CURL_OPT(CURLOPT_PROXYPASSWORD, NULL);
+#endif
                HTTP_CURL_OPT(CURLOPT_PROXYAUTH, 0L);
                HTTP_CURL_OPT(CURLOPT_HTTPPROXYTUNNEL, 0L);
                HTTP_CURL_OPT(CURLOPT_DNS_CACHE_TIMEOUT, 60L);
@@ -506,8 +508,10 @@ PHP_HTTP_API void _http_request_defaults(http_request *request)
                HTTP_CURL_OPT(CURLOPT_LOCALPORTRANGE, 0L);
 #endif
                /* libcurl < 7.19.6 does not clear auth info with USERPWD set to NULL */
+#if HTTP_CURL_VERSION(7,19,1)
                HTTP_CURL_OPT(CURLOPT_USERNAME, NULL);
                HTTP_CURL_OPT(CURLOPT_PASSWORD, NULL);
+#endif
                HTTP_CURL_OPT(CURLOPT_HTTPAUTH, 0L);
                HTTP_CURL_OPT(CURLOPT_ENCODING, NULL);
 #if HTTP_CURL_VERSION(7,16,2)
@@ -527,8 +531,9 @@ PHP_HTTP_API void _http_request_defaults(http_request *request)
                HTTP_CURL_OPT(CURLOPT_HTTPHEADER, NULL);
                HTTP_CURL_OPT(CURLOPT_COOKIE, NULL);
                HTTP_CURL_OPT(CURLOPT_COOKIESESSION, 0L);
+               /* these options would enable curl's cookie engine by default which we don't want
                HTTP_CURL_OPT(CURLOPT_COOKIEFILE, NULL);
-               HTTP_CURL_OPT(CURLOPT_COOKIEJAR, NULL);
+               HTTP_CURL_OPT(CURLOPT_COOKIEJAR, NULL); */
 #if HTTP_CURL_VERSION(7,14,1)
                HTTP_CURL_OPT(CURLOPT_COOKIELIST, NULL);
 #endif
@@ -1080,6 +1085,11 @@ PHP_HTTP_API void _http_request_exec(http_request *request)
 retry:
        if (CURLE_OK != (result = curl_easy_perform(request->ch))) {
                http_error_ex(HE_WARNING, HTTP_E_REQUEST, "%s; %s (%s)", curl_easy_strerror(result), http_request_storage_get(request->ch)->errorbuffer, request->url);
+#ifdef ZEND_ENGINE_2
+               if ((HTTP_G->only_exceptions || GLOBAL_ERROR_HANDLING == EH_THROW) && EG(exception)) {
+                       add_property_long(EG(exception), "curlCode", result);
+               }
+#endif
                
                if (request->_retry.count > tries++) {
                        switch (result) {