- deprecate HttpRequest::*RawPostData() in favour of ::*Body()
authorMichael Wallner <mike@php.net>
Fri, 2 Feb 2007 19:59:42 +0000 (19:59 +0000)
committerMichael Wallner <mike@php.net>
Fri, 2 Feb 2007 19:59:42 +0000 (19:59 +0000)
http.c
http_request_object.c
missing.h
php_http_request_object.h
php_http_std_defs.h
rebuild
tests/HttpRequest_006.phpt
tests/HttpRequest_008.phpt

diff --git a/http.c b/http.c
index f0ffeae62d1648c58c288db26e319cac796eb435..e55b35f67e9cec1641194e8af0e010b163186917 100644 (file)
--- 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);
index 292db7b6344fb1d014c2e8fb4e0ab4a7cf8afde2..cd1a30348877eb3828bec2c112f11fd2f4f2d52d 100644 (file)
@@ -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);
        }
 }
 /* }}} */
index 2a93ca74bdac980124e64fe43729071c1df75ef8..2da5c37ba025a68fbae97ce315dcd1330430c0f4 100644 (file)
--- a/missing.h
+++ b/missing.h
 
 #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
index 6e2eaaa941247707610f424263a2fa4b078be4b4..352ad51bb1bb5cbc97a51e33be10814d0b1c6240 100644 (file)
@@ -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);
index 8ca7c730ba7f2c6f5c6b61899a0607d925a41416..0d97c4dc4f1816f672f3706d3e96f7c33f63736d 100644 (file)
@@ -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 b7f97c87625337f93638713918682d88dba179a9..e32fd35e55754396d7b4c356c86db9e42dfccb52 100755 (executable)
--- 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
index 8996166fad6f060faaf09e66a088dcfc91f3e4c1..68c3ffecd84b420a478e2477f7d7a6a8709cb1e1 100644 (file)
@@ -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());
index a0125e815d71ee61c998c6a59a611833a542cb13..7b32439f8b724be2deb80c18c3f1ec6b161e3a71 100644 (file)
@@ -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());