- make request_exec() always succeed (picky curl)
authorMichael Wallner <mike@php.net>
Thu, 10 Nov 2005 15:54:13 +0000 (15:54 +0000)
committerMichael Wallner <mike@php.net>
Thu, 10 Nov 2005 15:54:13 +0000 (15:54 +0000)
docs/examples/tutorial.txt
http_message_object.c
http_request_api.c
http_request_object.c

index 96ee9de72cd4652ccb7b9c1f3e856a77beaa6ae4..fbe9f210758fc659d7bdec23bbd57f5fcf083dd6 100644 (file)
@@ -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 {
index a965a66f950a33aefeb987d176c191f6ad5335d9..bd15becf2e3e62747989e1fff4c7640597a2acc2 100644 (file)
@@ -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;
        }
index b92cbfe88b761d874cf3279979758c8f5ca98e5a..5d6b8f22dd0d778466c328b8d46ec56dda37cc68 100644 (file)
@@ -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;
 }
 /* }}} */
 
index 73d3718394848ecf3f4ff50aae370110dd86e0a9..2ed979789b009c8a93b2c983baca769b5a50a946 100644 (file)
@@ -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.
  *