From: Michael Wallner Date: Thu, 10 Nov 2005 15:54:13 +0000 (+0000) Subject: - make request_exec() always succeed (picky curl) X-Git-Tag: RELEASE_0_18_0~12 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=e7e38363a2e833933519deb5f649d34fd7cc658d;p=m6w6%2Fext-http - make request_exec() always succeed (picky curl) --- diff --git a/docs/examples/tutorial.txt b/docs/examples/tutorial.txt index 96ee9de..fbe9f21 100644 --- a/docs/examples/tutorial.txt +++ b/docs/examples/tutorial.txt @@ -28,7 +28,7 @@ $r->setQueryData( ); // HttpRequest::send() returns an HttpMessage object -// of type HttpMessage::RESPONSE or throws an exception +// of type HttpMessage::TYPE_RESPONSE or throws an exception try { print $r->send()->getBody(); } catch (HttpException $e) { @@ -62,6 +62,7 @@ $r->setPostFields( ) ); // add the file to post (form name, file name, file type) +touch('profile.jpg'); $r->addPostFile('image', 'profile.jpg', 'image/jpeg'); try { diff --git a/http_message_object.c b/http_message_object.c index a965a66..bd15bec 100644 --- a/http_message_object.c +++ b/http_message_object.c @@ -457,9 +457,7 @@ static void _http_message_object_write_prop(zval *object, zval *member, zval *va default: #ifdef WONKY - zval_ptr_dtor(&cpy); zend_get_std_object_handlers()->write_property(object, member, value TSRMLS_CC); - return; #endif break; } diff --git a/http_request_api.c b/http_request_api.c index b92cbfe..5d6b8f2 100644 --- a/http_request_api.c +++ b/http_request_api.c @@ -721,16 +721,19 @@ PHP_HTTP_API STATUS _http_request_exec(CURL *ch, HashTable *info, phpstr *respon http_request_conv(ch, response, request); /* perform request */ - if (CURLE_OK != (result = curl_easy_perform(ch))) { - http_error_ex(HE_WARNING, HTTP_E_REQUEST, "Could not perform request: %s", curl_easy_strerror(result)); - return FAILURE; - } else { - /* get curl info */ - if (info) { - http_request_info(ch, info); - } - return SUCCESS; + switch (result = curl_easy_perform(ch)) + { + default: + http_error(HE_WARNING, HTTP_E_REQUEST, curl_easy_strerror(result)); + case CURLE_OK: + /* get curl info */ + if (info) { + http_request_info(ch, info); + } + break; } + /* always succeeds */ + return SUCCESS; } /* }}} */ diff --git a/http_request_object.c b/http_request_object.c index 73d3718..2ed9797 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -1957,6 +1957,10 @@ PHP_METHOD(HttpRequest, clearHistory) * * Returns the received response as HttpMessage object. * + * NOTE: While an exception may be thrown, the transfer could have succeeded + * at least partially, so you might want to check the return values of various + * HttpRequest::getResponse*() methods. + * * Throws HttpRuntimeException, HttpRequestException, * HttpMalformedHeaderException, HttpEncodingException. *