PHP_FE(http_split_response, NULL)
PHP_FE(http_parse_headers, NULL)
PHP_FE(http_get_request_headers, NULL)
+ PHP_FE(http_get_request_body, NULL)
PHP_FE(http_match_request_header, NULL)
#ifdef HTTP_HAVE_CURL
PHP_FE(http_get, http_arg_pass_ref_3)
#include "php.h"
#include "ext/standard/url.h"
+#include "SAPI.h"
+
#include "php_http.h"
#include "php_http_std_defs.h"
#include "php_http_api.h"
}
/* }}} */
+/* {{{ zend_bool http_get_request_body(char **, size_t *) */
+PHP_HTTP_API STATUS _http_get_request_body_ex(char **body, size_t *length, zend_bool dup TSRMLS_DC)
+{
+ *length = 0;
+ *body = NULL;
+
+ if (SG(request_info).raw_post_data) {
+ *length = SG(request_info).raw_post_data_length;
+ *body = (char *) (dup ? estrndup(SG(request_info).raw_post_data, *length) : SG(request_info).raw_post_data);
+ return SUCCESS;
+ }
+ return FAILURE;
+}
+/* }}} */
/* {{{ char *http_chunked_decode(char *, size_t, char **, size_t *) */
PHP_HTTP_API const char *_http_chunked_decode(const char *encoded, size_t encoded_len,
}
/* }}} */
+/* {{{ proto string http_get_request_body(void)
+ *
+ * Get the raw request body (e.g. POST or PUT data).
+ */
+PHP_FUNCTION(http_get_request_body)
+{
+ char *body;
+ size_t length;
+
+ NO_ARGS;
+
+ if (SUCCESS == http_get_request_body(&body, &length)) {
+ RETURN_STRING(body, (int) length, 0);
+ } else {
+ RETURN_NULL();
+ }
+}
+/* }}} */
+
/* {{{ proto bool http_match_request_header(string header, string value[, bool match_case = false])
*
* Match an incoming HTTP header.
HTTP_STATIC_ME_ALIAS(splitResponse, http_split_response, NULL)
HTTP_STATIC_ME_ALIAS(parseHeaders, http_parse_headers, NULL)
HTTP_STATIC_ME_ALIAS(getRequestHeaders, http_get_request_headers, NULL)
+ HTTP_STATIC_ME_ALIAS(getRequestBody, http_get_request_body, NULL)
#ifdef HTTP_HAVE_CURL
HTTP_STATIC_ME_ALIAS(get, http_get, http_arg_pass_ref_3)
HTTP_STATIC_ME_ALIAS(head, http_head, http_arg_pass_ref_3)
PHP_FUNCTION(http_split_response);
PHP_FUNCTION(http_parse_headers);
PHP_FUNCTION(http_get_request_headers);
+PHP_FUNCTION(http_get_request_body);
PHP_FUNCTION(http_match_request_header);
#ifdef HTTP_HAVE_CURL
PHP_FUNCTION(http_get);
#define http_get_server_var_ex(v, s) _http_get_server_var_ex((v), (s), 0 TSRMLS_CC)
PHP_HTTP_API zval *_http_get_server_var_ex(const char *key, size_t key_size, zend_bool check TSRMLS_DC);
+#define http_get_request_body(b, l) _http_get_request_body_ex((b), (l), 1 TSRMLS_CC)
+#define http_get_Request_body_ex(b, l, d) _http_get_request_body_ex((b), (l), (d) TSRMLS_CC)
+PHP_HTTP_API STATUS _http_get_request_body_ex(char **body, size_t *length, zend_bool dup TSRMLS_DC);
+
#define http_chunked_decode(e, el, d, dl) _http_chunked_decode((e), (el), (d), (dl) TSRMLS_CC)
PHP_HTTP_API const char *_http_chunked_decode(const char *encoded, size_t encoded_len, char **decoded, size_t *decoded_len TSRMLS_DC);
PHP_METHOD(HttpUtil, splitResponse);
PHP_METHOD(HttpUtil, parseHeaders);
PHP_METHOD(HttpUtil, getRequestHeaders);
+PHP_METHOD(HttpUtil, getRequestBody);
#ifdef HTTP_HAVE_CURL
PHP_METHOD(HttpUtil, get);
PHP_METHOD(HttpUtil, head);