);
// 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) {
)
);
// add the file to post (form name, file name, file type)
+touch('profile.jpg');
$r->addPostFile('image', 'profile.jpg', 'image/jpeg');
try {
default:
#ifdef WONKY
- zval_ptr_dtor(&cpy);
zend_get_std_object_handlers()->write_property(object, member, value TSRMLS_CC);
- return;
#endif
break;
}
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;
}
/* }}} */
*
* 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.
*