- add HttpMessage::get(string $name)
authorMichael Wallner <mike@php.net>
Fri, 7 Jul 2006 11:49:30 +0000 (11:49 +0000)
committerMichael Wallner <mike@php.net>
Fri, 7 Jul 2006 11:49:30 +0000 (11:49 +0000)
docs/functions.html
http_message_object.c
package2.xml
php_http_message_object.h

index c3d2aadd6a26730de960b078d1fa091005377dc2..f78ada38c405890cf19963f4c2f7cb172c9b9a90 100644 (file)
@@ -513,6 +513,9 @@ HTTP messages.  Accepts an optional string parameter specifying the class to use
 <p>Set the body of the HttpMessage.<br />
 NOTE: Don't forget to update any headers accordingly.</p>
 <p>Expects a string parameter containing the new body of the message.</p>
+<h3 id="HttpMessage_getHeader">string HttpMessage::getHeader(string header)</h3>
+<p>Get message header.</p>
+<p>Returns the header value on success or NULL if the header does not exist.</p>
 <h3 id="HttpMessage_getHeaders">array HttpMessage::getHeaders()</h3>
 <p>Get Message Headers.</p>
 <p>Returns an associative array containing the messages HTTP headers.</p>
@@ -1287,6 +1290,7 @@ http.cache_log is set.</p>
 <li><a href="#HttpMessage_fromString">HttpMessage::fromString()</a></li>
 <li><a href="#HttpMessage_getBody">HttpMessage::getBody()</a></li>
 <li><a href="#HttpMessage_setBody">HttpMessage::setBody()</a></li>
+<li><a href="#HttpMessage_getHeader">HttpMessage::getHeader()</a></li>
 <li><a href="#HttpMessage_getHeaders">HttpMessage::getHeaders()</a></li>
 <li><a href="#HttpMessage_setHeaders">HttpMessage::setHeaders()</a></li>
 <li><a href="#HttpMessage_addHeaders">HttpMessage::addHeaders()</a></li>
@@ -1449,7 +1453,7 @@ http.cache_log is set.</p>
 </li>
 </ul>
 </div>
-    <p><b>Generated at: Thu, 06 Jul 2006 20:17:57 +0200</b></p>
+    <p><b>Generated at: Fri, 07 Jul 2006 13:48:43 +0200</b></p>
 </body>
 </html>
 
index a1b3141817d699faddc5d8b270f8cf92643a1d79..eb35995bed76a3d7eadcc7ba21aabbf78da06681 100644 (file)
@@ -55,6 +55,10 @@ HTTP_BEGIN_ARGS(setBody, 1)
        HTTP_ARG_VAL(body, 0)
 HTTP_END_ARGS;
 
+HTTP_BEGIN_ARGS(getHeader, 1)
+       HTTP_ARG_VAL(header, 0)
+HTTP_END_ARGS;
+
 HTTP_EMPTY_ARGS(getHeaders);
 HTTP_BEGIN_ARGS(setHeaders, 1)
        HTTP_ARG_VAL(headers, 0)
@@ -140,6 +144,7 @@ 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(getHeader, ZEND_ACC_PUBLIC)
        HTTP_MESSAGE_ME(getHeaders, ZEND_ACC_PUBLIC)
        HTTP_MESSAGE_ME(setHeaders, ZEND_ACC_PUBLIC)
        HTTP_MESSAGE_ME(addHeaders, ZEND_ACC_PUBLIC)
@@ -783,6 +788,31 @@ PHP_METHOD(HttpMessage, setBody)
 }
 /* }}} */
 
+/* {{{ proto string HttpMessage::getHeader(string header)
+ *
+ * Get message header.
+ *
+ * Returns the header value on success or NULL if the header does not exist.
+ */
+PHP_METHOD(HttpMessage, getHeader)
+{
+       zval *header;
+       char *orig_header, *nice_header;
+       int header_len;
+       getObject(http_message_object, obj);
+       
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &orig_header, &header_len)) {
+               RETURN_FALSE;
+       }
+       
+       nice_header = pretty_key(estrndup(orig_header, header_len), header_len, 1, 1);
+       if ((header = http_message_header_ex(obj->message, nice_header, header_len + 1))) {
+               RETVAL_ZVAL(header, 1, 0);
+       }
+       efree(nice_header);
+}
+/* }}} */
+
 /* {{{ proto array HttpMessage::getHeaders()
  *
  * Get Message Headers.
index 275c6db2f6eabb1c1b5831ef3e8519a9513b1c15..646928ffe2ff9195101e9571e86e9aca07fe40fb 100644 (file)
@@ -40,7 +40,8 @@ support. Parallel requests are available for PHP 5 and greater.
  <license>BSD, revised</license>
  <notes><![CDATA[
 * Fixed HttpResponse::capture() failure if buffered output exceeds 40k
-* Added HttpQueryString::mod() method
+* Added HttpQueryString::mod(array $params) method
+* Added HttpMessage::get(string $name) method
 ]]></notes>
  <contents>
   <dir name="/">
index 38030ad3c002dba333ecf9b571e4284c0eabb373..7f47167a049c37dcb5a7f72e7ae66f7ea35a179c 100644 (file)
@@ -80,6 +80,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, getHeader);
 PHP_METHOD(HttpMessage, getHeaders);
 PHP_METHOD(HttpMessage, setHeaders);
 PHP_METHOD(HttpMessage, addHeaders);