- added missing HttpMessage::setBody()
authorMichael Wallner <mike@php.net>
Mon, 12 Sep 2005 12:55:35 +0000 (12:55 +0000)
committerMichael Wallner <mike@php.net>
Mon, 12 Sep 2005 12:55:35 +0000 (12:55 +0000)
http_message_object.c
package.xml
php_http_message_object.h

index 51e2ca21831261083f6bc6a1c30c8c609640a5ca..a09c83b53be0e08d72fc3272ea13fda3660288c8 100644 (file)
@@ -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.
index c0868dd6a9262b8e4906d21463ba1a06b167155b..e83b2069b3e1d1daabed7767bd784bfd2d2fa832 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 <!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0">
-<!-- $Revision: 1.41 $ -->
+<!-- $Revision: 1.42 $ -->
 <package version="1.0">
   <name>pecl_http</name>
   <summary>Extended HTTP support</summary>
@@ -35,6 +35,7 @@
     <state>beta</state>
     <notes><![CDATA[
 + Added missing support for raw post data in HttpRequest
++ Added missing HttpMessage::setBody()
 ]]>
     </notes>
   </release>
index b3d4c1487738efe45bdc30dc2f8a23a6d6dd9258..1e95c7490f1f633ebacf46947b13f8981bb2170c 100644 (file)
@@ -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);