- added missing http_request() function stub
authorMichael Wallner <mike@php.net>
Thu, 6 Apr 2006 13:50:32 +0000 (13:50 +0000)
committerMichael Wallner <mike@php.net>
Thu, 6 Apr 2006 13:50:32 +0000 (13:50 +0000)
http.c
http_functions.c
package2.xml
php_http.h

diff --git a/http.c b/http.c
index d514b3841efa4adb28eaa978a37a4996de27d51b..807910a4226ee9564bc460eb77a4610063f80440 100644 (file)
--- a/http.c
+++ b/http.c
@@ -105,6 +105,7 @@ zend_function_entry http_functions[] = {
        PHP_FE(http_put_data, http_arg_pass_ref_4)
        PHP_FE(http_put_file, http_arg_pass_ref_4)
        PHP_FE(http_put_stream, http_arg_pass_ref_4)
+       PHP_FE(http_request, http_arg_pass_ref_5)
 #endif
        PHP_FE(http_request_method_register, NULL)
        PHP_FE(http_request_method_unregister, NULL)
index 2cd1dfe554b4d5974253b35efed8eb37e5201186..89a8c61ca093c6ca1086a513e8121830676f73fd 100644 (file)
@@ -1624,6 +1624,49 @@ PHP_FUNCTION(http_put_data)
        http_request_dtor(&request);
 }
 /* }}} */
+
+/* {{{ proto string http_request(int method, string url[, string body[, array options[, array &info]]])
+ *
+ * Performs a custom HTTP request on the supplied url.
+ *
+ * Expects the first parameter to be an integer specifying the request method to use.
+ * Accepts an optional third string parameter containing the raw request body.
+ * See http_get() for a full list of available options.
+ *
+ * Returns the HTTP response(s) as string on success, or FALSE on failure.
+ */
+PHP_FUNCTION(http_request)
+{
+       long meth;
+       char *URL, *data = NULL;
+       int URL_len, data_len = 0;
+       zval *options = NULL, *info = NULL;
+       http_request_body body;
+       http_request request;
+       
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls|sa/!z", &meth, &URL, &URL_len, &data, &data_len, &options, &info)) {
+               RETURN_FALSE;
+       }
+       
+       if (info) {
+               zval_dtor(info);
+               array_init(info);
+       }
+       
+       RETVAL_FALSE;
+       
+       http_request_init_ex(&request, NULL, meth, URL);
+       request.body = http_request_body_init_ex(&body, HTTP_REQUEST_BODY_CSTRING, data, data_len, 0);
+       if (SUCCESS == http_request_prepare(&request, options?Z_ARRVAL_P(options):NULL)) {
+               http_request_exec(&request);
+               if (info) {
+                       http_request_info(&request, Z_ARRVAL_P(info));
+               }
+               RETVAL_RESPONSE_OR_BODY(request);
+       }
+       http_request_dtor(&request);
+}
+/* }}} */
 #endif /* HTTP_HAVE_CURL */
 /* }}} HAVE_CURL */
 
index 892f1c8dcaa3145e3a49a3a52a568347ca3e516b..1a2e49536290bee1f9cd8da58bcde4b65df7089d 100644 (file)
@@ -46,6 +46,7 @@ HttpResponse
  </stability>
  <license>BSD, revised</license>
  <notes><![CDATA[
++ Added missing http_request() function
 - Improved performance of the message and header parser
 - Disallow $HttpMessage->prepend($HttpMessage) causing infinite recursion
 * Fixed internal http_parse_headers() always returning success
index 32ce1e365123d6af1f8a15943a52130c7f654a2c..6ff5418ceb137ad5f5c98776e09a3144fab763a8 100644 (file)
@@ -181,6 +181,7 @@ PHP_FUNCTION(http_post_fields);
 PHP_FUNCTION(http_put_data);
 PHP_FUNCTION(http_put_file);
 PHP_FUNCTION(http_put_stream);
+PHP_FUNCTION(http_request);
 #endif /* HTTP_HAVE_CURL */
 PHP_FUNCTION(http_request_method_register);
 PHP_FUNCTION(http_request_method_unregister);