From: Michael Wallner Date: Mon, 12 Sep 2005 12:55:35 +0000 (+0000) Subject: - added missing HttpMessage::setBody() X-Git-Tag: RELEASE_0_14_0~36 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=61ced187b8a3a3c21578d253e37d1a076aa0aed4;p=m6w6%2Fext-http - added missing HttpMessage::setBody() --- diff --git a/http_message_object.c b/http_message_object.c index 51e2ca2..a09c83b 100644 --- a/http_message_object.c +++ b/http_message_object.c @@ -47,6 +47,10 @@ HTTP_BEGIN_ARGS(fromString, 1, 1) HTTP_END_ARGS; HTTP_EMPTY_ARGS(getBody, 0); +HTTP_BEGIN_ARGS(setBody, 0, 1) + HTTP_ARG_VAL(body) +HTTP_END_ARGS; + HTTP_EMPTY_ARGS(getHeaders, 0); HTTP_BEGIN_ARGS(setHeaders, 0, 1) HTTP_ARG_VAL(headers, 0) @@ -103,6 +107,7 @@ zend_class_entry *http_message_object_ce; zend_function_entry http_message_object_fe[] = { HTTP_MESSAGE_ME(__construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) HTTP_MESSAGE_ME(getBody, ZEND_ACC_PUBLIC) + HTTP_MESSAGE_ME(setBody, ZEND_ACC_PUBLIC) HTTP_MESSAGE_ME(getHeaders, ZEND_ACC_PUBLIC) HTTP_MESSAGE_ME(setHeaders, ZEND_ACC_PUBLIC) HTTP_MESSAGE_ME(addHeaders, ZEND_ACC_PUBLIC) @@ -522,6 +527,24 @@ PHP_METHOD(HttpMessage, getBody) } /* }}} */ +/* {{{ proto void HttpMessage::setBody(string body) + * + * Set the body of the HttpMessage. + * NOTE: Don't forget to update any headers accordingly. + */ +PHP_METHOD(HttpMessage, setBody) +{ + char *body; + int len; + getObject(http_message_object, obj); + + if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &body, &len)) { + phpstr_dtor(PHPSTR(obj->message)); + phpstr_from_string_ex(PHPSTR(obj->message), body, len); + } +} +/* }}} */ + /* {{{ proto array HttpMessage::getHeaders() * * Get Message Headers. diff --git a/package.xml b/package.xml index c0868dd..e83b206 100644 --- a/package.xml +++ b/package.xml @@ -1,6 +1,6 @@ - + pecl_http Extended HTTP support @@ -35,6 +35,7 @@ beta diff --git a/php_http_message_object.h b/php_http_message_object.h index b3d4c14..1e95c74 100644 --- a/php_http_message_object.h +++ b/php_http_message_object.h @@ -67,6 +67,7 @@ extern void _http_message_object_free(zend_object *object TSRMLS_DC); PHP_METHOD(HttpMessage, __construct); PHP_METHOD(HttpMessage, getBody); +PHP_METHOD(HttpMessage, setBody); PHP_METHOD(HttpMessage, getHeaders); PHP_METHOD(HttpMessage, setHeaders); PHP_METHOD(HttpMessage, addHeaders);