- fix warning
authorMichael Wallner <mike@php.net>
Mon, 12 Dec 2005 22:21:38 +0000 (22:21 +0000)
committerMichael Wallner <mike@php.net>
Mon, 12 Dec 2005 22:21:38 +0000 (22:21 +0000)
- improve request error messages

config.w32
http_request_api.c
http_request_pool_api.c
php_http.h
php_http_request_api.h

index e18d586466cd7538e851bd76d0c1130ab9c5f59c..cc7a938d3d6b38559f4d8ffa069347cd877d1fed 100644 (file)
@@ -95,7 +95,6 @@ if (PHP_HTTP != "no") {
                AC_DEFINE("HAVE_CURL_MULTI_STRERROR", 1, "");
                AC_DEFINE("HAVE_CURL_EASY_STRERROR", 1, "");
                AC_DEFINE("HAVE_CURL_EASY_RESET", 1, "");
-               AC_DEFINE("CURL_STATICLIB", 1, "");
        } else {
                WARNING("curl convenience functions not enabled; libraries and headers not found");
        }
index b0a845dc4b84944869fe82a020b9b08fcba8f766..42a1199bc8377537b18a74c41f2d0eea71e3d06e 100644 (file)
@@ -292,6 +292,8 @@ PHP_HTTP_API void _http_request_defaults(http_request *request)
 #if defined(ZTS)
                HTTP_CURL_OPT(NOSIGNAL, 1);
 #endif
+               HTTP_CURL_OPT(PRIVATE, request);
+               HTTP_CURL_OPT(ERRORBUFFER, request->_error);
                HTTP_CURL_OPT(HEADER, 0);
                HTTP_CURL_OPT(FILETIME, 1);
                HTTP_CURL_OPT(AUTOREFERER, 1);
@@ -380,7 +382,6 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti
        /* set options */
        HTTP_CURL_OPT(DEBUGDATA, request);
        HTTP_CURL_OPT(URL, request->url);
-       HTTP_CURL_OPT(PRIVATE, request->url);
 
        /* progress callback */
        if ((zoption = http_request_option(request, options, "onprogress", 0))) {
@@ -670,7 +671,7 @@ PHP_HTTP_API void _http_request_exec(http_request *request)
        TSRMLS_FETCH_FROM_CTX(request->tsrm_ls);
        
        if (CURLE_OK != (result = curl_easy_perform(request->ch))) {
-               http_error_ex(HE_WARNING, HTTP_E_REQUEST, "%s (%s)", curl_easy_strerror(result), request->url);
+               http_error_ex(HE_WARNING, HTTP_E_REQUEST, "%s; %s (%s)", curl_easy_strerror(result), request->_error, request->url);
        }
 }
 /* }}} */
index 191ab446d2e763597c51a2565dbc243ae6e60c12..7c3732004f71d784d69c4289745b648ab573e92f 100644 (file)
@@ -256,9 +256,9 @@ PHP_HTTP_API int _http_request_pool_perform(http_request_pool *pool TSRMLS_DC)
                if (CURLMSG_DONE == msg->msg) {
                        if (CURLE_OK != msg->data.result) {
                                http_request_pool_try {
-                                       char *url = NULL;
-                                       curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &url);
-                                       http_error_ex(HE_WARNING, HTTP_E_REQUEST, "%s (%s)", curl_easy_strerror(msg->data.result), url);
+                                       http_request *r = NULL;
+                                       curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &r);
+                                       http_error_ex(HE_WARNING, HTTP_E_REQUEST, "%s; %s (%s)", curl_easy_strerror(msg->data.result), r?r->_error:"", r?r->url:"");
                                } http_request_pool_catch();
                        }
                        http_request_pool_try {
index e646c20097b0688056f30d62103ccc00bba969d2..dce7b5982899ea34bf6b934b6690478a8bd341af 100644 (file)
@@ -22,7 +22,6 @@
 #include "phpstr/phpstr.h"
 #include "missing.h"
 
-
 #ifdef HTTP_WANT_NETDB
 #      ifdef PHP_WIN32
 #              include <winsock2.h>
@@ -34,6 +33,7 @@
 #if defined(HTTP_WANT_CURL) && defined(HTTP_HAVE_CURL)
 #      ifdef PHP_WIN32
 #              include <winsock2.h>
+#              define CURL_STATICLIB
 #      endif
 #      include <curl/curl.h>
 #endif
index 52be0949f78e453f3d59358f50fd99c353ac5e9e..9608611ab00a33bd2c720cf38f0180e4513d59e5 100644 (file)
@@ -41,6 +41,7 @@ typedef struct {
                struct curl_slist *headers;
        } _cache;
        
+       char _error[CURL_ERROR_SIZE];
        zval *_progress_callback;
 
 #ifdef ZTS