From: Michael Wallner Date: Fri, 2 Feb 2007 19:59:42 +0000 (+0000) Subject: - deprecate HttpRequest::*RawPostData() in favour of ::*Body() X-Git-Tag: RELEASE_1_5_0_RC1~15 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=accf1817e811a7edabd687ef6105983f39f13942;p=m6w6%2Fext-http - deprecate HttpRequest::*RawPostData() in favour of ::*Body() --- diff --git a/http.c b/http.c index f0ffeae..e55b35f 100644 --- a/http.c +++ b/http.c @@ -445,7 +445,7 @@ PHP_MINFO_FUNCTION(http) phpstr_init(&s); FOREACH_HASH_KEYVAL(pos, ht, key, val) { - phpstr_appendf(&s, "%s (%d), ", key.str, Z_LVAL_PP(val)); + phpstr_appendf(&s, "%s (%ld), ", key.str, Z_LVAL_PP(val)); } zend_hash_destroy(ht); FREE_HASHTABLE(ht); diff --git a/http_request_object.c b/http_request_object.c index 292db7b..cd1a303 100644 --- a/http_request_object.c +++ b/http_request_object.c @@ -33,6 +33,7 @@ #define HTTP_EMPTY_ARGS(method) HTTP_EMPTY_ARGS_EX(HttpRequest, method, 0) #define HTTP_REQUEST_ME(method, visibility) PHP_ME(HttpRequest, method, HTTP_ARGS(HttpRequest, method), visibility) #define HTTP_REQUEST_ALIAS(method, func) HTTP_STATIC_ME_ALIAS(method, func, HTTP_ARGS(HttpRequest, method)) +#define HTTP_REQUEST_MALIAS(me, al, vis) ZEND_FENTRY(me, ZEND_MN(HttpRequest_##al), HTTP_ARGS(HttpRequest, al), vis) HTTP_BEGIN_ARGS(__construct, 0) HTTP_ARG_VAL(url, 0) @@ -130,13 +131,13 @@ HTTP_BEGIN_ARGS(addPostFile, 2) HTTP_ARG_VAL(content_type, 0) HTTP_END_ARGS; -HTTP_EMPTY_ARGS(getRawPostData); -HTTP_BEGIN_ARGS(setRawPostData, 0) - HTTP_ARG_VAL(raw_post_data, 0) +HTTP_EMPTY_ARGS(getBody); +HTTP_BEGIN_ARGS(setBody, 0) + HTTP_ARG_VAL(request_body_data, 0) HTTP_END_ARGS; -HTTP_BEGIN_ARGS(addRawPostData, 1) - HTTP_ARG_VAL(raw_post_data, 0) +HTTP_BEGIN_ARGS(addBody, 1) + HTTP_ARG_VAL(request_body_data, 0) HTTP_END_ARGS; HTTP_EMPTY_ARGS(getPutFile); @@ -289,9 +290,12 @@ zend_function_entry http_request_object_fe[] = { HTTP_REQUEST_ME(getPostFields, ZEND_ACC_PUBLIC) HTTP_REQUEST_ME(addPostFields, ZEND_ACC_PUBLIC) - HTTP_REQUEST_ME(setRawPostData, ZEND_ACC_PUBLIC) - HTTP_REQUEST_ME(getRawPostData, ZEND_ACC_PUBLIC) - HTTP_REQUEST_ME(addRawPostData, ZEND_ACC_PUBLIC) + HTTP_REQUEST_ME(setBody, ZEND_ACC_PUBLIC) + HTTP_REQUEST_ME(getBody, ZEND_ACC_PUBLIC) + HTTP_REQUEST_ME(addBody, ZEND_ACC_PUBLIC) + HTTP_REQUEST_MALIAS(setRawPostData, setBody, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED) + HTTP_REQUEST_MALIAS(getRawPostData, getBody, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED) + HTTP_REQUEST_MALIAS(addRawPostData, addBody, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED) HTTP_REQUEST_ME(setPostFiles, ZEND_ACC_PUBLIC) HTTP_REQUEST_ME(addPostFile, ZEND_ACC_PUBLIC) @@ -356,7 +360,7 @@ PHP_MINIT_FUNCTION(http_request_object) DCL_PROP(PRIVATE, long, method, HTTP_GET); DCL_PROP(PRIVATE, string, url, ""); DCL_PROP(PRIVATE, string, contentType, ""); - DCL_PROP(PRIVATE, string, rawPostData, ""); + DCL_PROP(PRIVATE, string, requestBody, ""); DCL_PROP(PRIVATE, string, queryData, ""); DCL_PROP(PRIVATE, string, putFile, ""); DCL_PROP(PRIVATE, string, putData, ""); @@ -585,8 +589,8 @@ STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_ case HTTP_POST: default: { - /* check for raw post data */ - zval *raw_data = GET_PROP(rawPostData); + /* check for raw request body */ + zval *raw_data = GET_PROP(requestBody); if (Z_STRLEN_P(raw_data)) { http_request_object_check_request_content_type(getThis()); @@ -1255,9 +1259,9 @@ PHP_METHOD(HttpRequest, getPostFields) } /* }}} */ -/* {{{ proto bool HttpRequest::setRawPostData([string raw_post_data]) - Set raw post data to send, overwriting previously set raw post data. Don't forget to specify a content type. */ -PHP_METHOD(HttpRequest, setRawPostData) +/* {{{ proto bool HttpRequest::setBody([string request_body_data]) + Set request body to send, overwriting previously set request body. Don't forget to specify a content type. */ +PHP_METHOD(HttpRequest, setBody) { char *raw_data = NULL; int data_len = 0; @@ -1270,14 +1274,14 @@ PHP_METHOD(HttpRequest, setRawPostData) raw_data = ""; } - UPD_STRL(rawPostData, raw_data, data_len); + UPD_STRL(requestBody, raw_data, data_len); RETURN_TRUE; } /* }}} */ -/* {{{ proto bool HttpRequest::addRawPostData(string raw_post_data) - Add raw post data, leaving previously set raw post data unchanged. */ -PHP_METHOD(HttpRequest, addRawPostData) +/* {{{ proto bool HttpRequest::addBody(string request_body_data) + Add request body data, leaving previously set request body data unchanged. */ +PHP_METHOD(HttpRequest, addBody) { char *raw_data; int data_len; @@ -1287,7 +1291,7 @@ PHP_METHOD(HttpRequest, addRawPostData) } if (data_len) { - zval *data = GET_PROP(rawPostData); + zval *data = GET_PROP(rrequestBody); if (Z_STRLEN_P(data)) { Z_STRVAL_P(data) = erealloc(Z_STRVAL_P(data), (Z_STRLEN_P(data) += data_len) + 1); @@ -1302,14 +1306,14 @@ PHP_METHOD(HttpRequest, addRawPostData) } /* }}} */ -/* {{{ proto string HttpRequest::getRawPostData() - Get previously set raw post data. */ -PHP_METHOD(HttpRequest, getRawPostData) +/* {{{ proto string HttpRequest::getBody() + Get previously set request body data. */ +PHP_METHOD(HttpRequest, getBody) { NO_ARGS; if (return_value_used) { - RETURN_PROP(rawPostData); + RETURN_PROP(requestBody); } } /* }}} */ diff --git a/missing.h b/missing.h index 2a93ca7..2da5c37 100644 --- a/missing.h +++ b/missing.h @@ -17,12 +17,62 @@ #include "php_version.h" +#if (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION == 0) +# define WONKY +#endif + #ifndef pemalloc_rel # define pemalloc_rel(size, persistent) ((persistent)?malloc(size):emalloc_rel(size)) #endif -#if (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION == 0) -# define WONKY +#ifndef ZEND_ACC_DEPRECATED +# define ZEND_ACC_DEPRECATED 0 +#endif + +#if PHP_MAJOR_VERSION == 4 && PHP_MINOR_VERSION == 3 && PHP_RELEASE_VERSION < 10 +# define php_url_parse_ex(u, l) php_url_parse(u) +#endif + +#ifndef TSRMLS_FETCH_FROM_CTX +# ifdef ZTS +# define TSRMLS_FETCH_FROM_CTX(ctx) void ***tsrm_ls = (void ***) ctx +# else +# define TSRMLS_FETCH_FROM_CTX(ctx) +# endif +#endif + +#ifndef TSRMLS_SET_CTX +# ifdef ZTS +# define TSRMLS_SET_CTX(ctx) ctx = (void ***) tsrm_ls +# else +# define TSRMLS_SET_CTX(ctx) +# endif +#endif + +#ifndef ZVAL_ZVAL +#define ZVAL_ZVAL(z, zv, copy, dtor) { \ + int is_ref, refcount; \ + is_ref = (z)->is_ref; \ + refcount = (z)->refcount; \ + *(z) = *(zv); \ + if (copy) { \ + zval_copy_ctor(z); \ + } \ + if (dtor) { \ + if (!copy) { \ + ZVAL_NULL(zv); \ + } \ + zval_ptr_dtor(&zv); \ + } \ + (z)->is_ref = is_ref; \ + (z)->refcount = refcount; \ + } +#endif +#ifndef RETVAL_ZVAL +#define RETVAL_ZVAL(zv, copy, dtor) ZVAL_ZVAL(return_value, zv, copy, dtor) +#endif +#ifndef RETURN_ZVAL +#define RETURN_ZVAL(zv, copy, dtor) { RETVAL_ZVAL(zv, copy, dtor); return; } #endif #ifdef WONKY diff --git a/php_http_request_object.h b/php_http_request_object.h index 6e2eaaa..352ad51 100644 --- a/php_http_request_object.h +++ b/php_http_request_object.h @@ -72,9 +72,9 @@ PHP_METHOD(HttpRequest, addQueryData); PHP_METHOD(HttpRequest, setPostFields); PHP_METHOD(HttpRequest, getPostFields); PHP_METHOD(HttpRequest, addPostFields); -PHP_METHOD(HttpRequest, getRawPostData); -PHP_METHOD(HttpRequest, setRawPostData); -PHP_METHOD(HttpRequest, addRawPostData); +PHP_METHOD(HttpRequest, getBody); +PHP_METHOD(HttpRequest, setBody); +PHP_METHOD(HttpRequest, addBody); PHP_METHOD(HttpRequest, addPostFile); PHP_METHOD(HttpRequest, setPostFiles); PHP_METHOD(HttpRequest, getPostFiles); diff --git a/php_http_std_defs.h b/php_http_std_defs.h index 8ca7c73..0d97c4d 100644 --- a/php_http_std_defs.h +++ b/php_http_std_defs.h @@ -258,10 +258,6 @@ typedef int STATUS; # define ZEND_EXCEPTION_GET_DEFAULT() zend_exception_get_default() #endif -#if PHP_MAJOR_VERSION == 4 && PHP_MINOR_VERSION == 3 && PHP_RELEASE_VERSION < 10 -# define php_url_parse_ex(u, l) php_url_parse(u) -#endif - #ifndef E_THROW # define E_THROW 0 #endif @@ -381,48 +377,6 @@ typedef int STATUS; # define curl_multi_strerror(dummy) "unknown error" #endif -#ifndef TSRMLS_FETCH_FROM_CTX -# ifdef ZTS -# define TSRMLS_FETCH_FROM_CTX(ctx) void ***tsrm_ls = (void ***) ctx -# else -# define TSRMLS_FETCH_FROM_CTX(ctx) -# endif -#endif - -#ifndef TSRMLS_SET_CTX -# ifdef ZTS -# define TSRMLS_SET_CTX(ctx) ctx = (void ***) tsrm_ls -# else -# define TSRMLS_SET_CTX(ctx) -# endif -#endif - -#ifndef ZVAL_ZVAL -#define ZVAL_ZVAL(z, zv, copy, dtor) { \ - int is_ref, refcount; \ - is_ref = (z)->is_ref; \ - refcount = (z)->refcount; \ - *(z) = *(zv); \ - if (copy) { \ - zval_copy_ctor(z); \ - } \ - if (dtor) { \ - if (!copy) { \ - ZVAL_NULL(zv); \ - } \ - zval_ptr_dtor(&zv); \ - } \ - (z)->is_ref = is_ref; \ - (z)->refcount = refcount; \ - } -#endif -#ifndef RETVAL_ZVAL -#define RETVAL_ZVAL(zv, copy, dtor) ZVAL_ZVAL(return_value, zv, copy, dtor) -#endif -#ifndef RETURN_ZVAL -#define RETURN_ZVAL(zv, copy, dtor) { RETVAL_ZVAL(zv, copy, dtor); return; } -#endif - #define PHP_MINIT_CALL(func) PHP_MINIT(func)(INIT_FUNC_ARGS_PASSTHRU) #define PHP_RINIT_CALL(func) PHP_RINIT(func)(INIT_FUNC_ARGS_PASSTHRU) #define PHP_MSHUTDOWN_CALL(func) PHP_MSHUTDOWN(func)(SHUTDOWN_FUNC_ARGS_PASSTHRU) diff --git a/rebuild b/rebuild index b7f97c8..e32fd35 100755 --- a/rebuild +++ b/rebuild @@ -3,6 +3,7 @@ rm -f warnings if test -d "$1"; then PREFIX=$1 + shift else PREFIX=`dirname $(dirname $(which php-config))` fi @@ -19,7 +20,7 @@ echo "DONE" echo -n "configuring... " CFLAGS="-Wall -Wextra -Wno-unused-parameter -Wfloat-equal -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wcast-align -Wmissing-field-initializers -Wnested-externs" \ - ./configure --with-php-config=${PREFIX}/bin/php-config $2 >/dev/null + ./configure --with-php-config=${PREFIX}/bin/php-config $@ >/dev/null if test $? -ne 0 ; then echo "FAILED!" exit 1 diff --git a/tests/HttpRequest_006.phpt b/tests/HttpRequest_006.phpt index 8996166..68c3ffe 100644 --- a/tests/HttpRequest_006.phpt +++ b/tests/HttpRequest_006.phpt @@ -12,7 +12,7 @@ echo "-TEST\n"; $r = new HttpRequest('http://dev.iworks.at/.print_request.php', HTTP_METH_POST); $r->setContentType('text/xml'); -$r->setRawPostData(xmlrpc_encode_request('testMethod', array('foo' => 'bar'))); +$r->setBody(xmlrpc_encode_request('testMethod', array('foo' => 'bar'))); var_dump($r->send()); var_dump($r->send()); var_dump($r->send()); diff --git a/tests/HttpRequest_008.phpt b/tests/HttpRequest_008.phpt index a0125e8..7b32439 100644 --- a/tests/HttpRequest_008.phpt +++ b/tests/HttpRequest_008.phpt @@ -12,7 +12,7 @@ echo "-TEST\n"; HttpRequest::methodRegister('foobar'); $r = new HttpRequest('http://dev.iworks.at/.print_request.php', HttpRequest::METH_FOOBAR); $r->setContentType('text/plain'); -$r->setRawPostData('Yep, this is FOOBAR!'); +$r->setBody('Yep, this is FOOBAR!'); var_dump($r->send()->getResponseCode()); var_dump($r->getRawRequestMessage());