/* $Id$ */
-
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
-#include "php.h"
+
+#define HTTP_WANT_CURL
+#include "php_http.h"
#if defined(ZEND_ENGINE_2) && defined(HTTP_HAVE_CURL)
#include "zend_interfaces.h"
-#include "php_http_std_defs.h"
-#include "php_http_request_object.h"
-#include "php_http_request_api.h"
-#include "php_http_request_pool_api.h"
-#include "php_http.h"
#include "php_http_api.h"
-#include "php_http_url_api.h"
+#include "php_http_exception_object.h"
#include "php_http_message_api.h"
#include "php_http_message_object.h"
-#include "php_http_exception_object.h"
-
-#include "missing.h"
-
-#ifdef PHP_WIN32
-# include <winsock2.h>
-#endif
-#include <curl/curl.h>
+#include "php_http_request_api.h"
+#include "php_http_request_object.h"
+#include "php_http_request_pool_api.h"
+#include "php_http_url_api.h"
ZEND_EXTERN_MODULE_GLOBALS(http);
* Set the request method.
*
* Expects an int as parameter specifying the request method to use.
- * In PHP 5.1+ HttpRequest::METH, otherwise the HTTP_METH constants can be used.
+ * In PHP 5.1+ HttpRequest::METH_*, otherwise the HTTP_METH_* constants can be used.
*
* Returns TRUE on success, or FALSE on failure.
*/
getObject(http_request_object, obj);
SET_EH_THROW_HTTP();
- if (msg = http_message_parse(PHPSTR_VAL(&obj->request), PHPSTR_LEN(&obj->request))) {
+ if ((msg = http_message_parse(PHPSTR_VAL(&obj->request), PHPSTR_LEN(&obj->request)))) {
ZVAL_OBJVAL(return_value, http_message_object_new_ex(http_message_object_ce, msg, NULL));
}
SET_EH_NORMAL();
getObject(http_request_object, obj);
SET_EH_THROW_HTTP();
- if (msg = http_message_parse(PHPSTR_VAL(&obj->history), PHPSTR_LEN(&obj->history))) {
+ if ((msg = http_message_parse(PHPSTR_VAL(&obj->history), PHPSTR_LEN(&obj->history)))) {
ZVAL_OBJVAL(return_value, http_message_object_new_ex(http_message_object_ce, msg, NULL));
}
SET_EH_NORMAL();
*
* 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.
*
* GET example:
* <pre>
* <?php
- * $r = new HttpRequest('http://example.com/feed.rss', HTTP_GET);
+ * $r = new HttpRequest('http://example.com/feed.rss', HttpRequest::METH_GET);
* $r->setOptions(array('lastmodified' => filemtime('local.rss')));
* $r->addQueryData(array('category' => 3));
* try {
* POST example:
* <pre>
* <?php
- * $r = new HttpRequest('http://example.com/form.php', HTTP_POST);
+ * $r = new HttpRequest('http://example.com/form.php', HttpRequest::METH_POST);
* $r->setOptions(array('cookies' => array('lang' => 'de')));
* $r->addPostFields(array('user' => 'mike', 'pass' => 's3c|r3t'));
* $r->addPostFile('image', 'profile.jpg', 'image/jpeg');