cvs: pecl /http http_message_api.c
| From: | Michael Wallner | Date: | Mon, 11 Apr 2005 07:12:18 +0000 |
| Subject: | cvs: pecl /http http_message_api.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-2966@lists.php.net to get a copy of this message | ||
mike Mon Apr 11 03:12:18 2005 EDT
Modified files:
/pecl/http http_message_api.c
Log:
- a header may have an array of values
http://cvs.php.net/diff.php/pecl/http/http_message_api.c?r1=1.2&r2=1.3&ty=u
Index: pecl/http/http_message_api.c
diff -u pecl/http/http_message_api.c:1.2 pecl/http/http_message_api.c:1.3
--- pecl/http/http_message_api.c:1.2 Mon Apr 11 02:52:08 2005
+++ pecl/http/http_message_api.c Mon Apr 11 03:12:17 2005
@@ -13,7 +13,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: http_message_api.c,v 1.2 2005/04/11 06:52:08 mike Exp $ */
+/* $Id: http_message_api.c,v 1.3 2005/04/11 07:12:17 mike Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -138,6 +138,7 @@
zval **header;
phpstr_init_ex(&str, msg->len, 1);
+ str.size = 4096;
switch (msg->type)
{
@@ -157,13 +158,29 @@
FOREACH_HASH_KEYVAL(&msg->hdrs, key, idx, header) {
if (key) {
- phpstr_appendf(&str, "%s: %s" HTTP_CRLF, key, Z_STRVAL_PP(header));
+ switch (Z_TYPE_PP(header))
+ {
+ case IS_STRING:
+ phpstr_appendf(&str, "%s: %s" HTTP_CRLF, key, Z_STRVAL_PP(header));
+ break;
+
+ case IS_ARRAY:
+ {
+ zval **single_header;
+
+ FOREACH_VAL(*header, single_header) {
+ phpstr_appendf(&str, "%s: %s" HTTP_CRLF, key, Z_STRVAL_PP(single_header));
+ }
+ }
+ break;
+ }
+
key = NULL;
}
}
phpstr_appends(&str, HTTP_CRLF);
- phpstr_append(&str, msg->body.data, msg->body.used);
+ phpstr_append(&str, PHPSTR_VAL(msg), PHPSTR_LEN(msg));
phpstr_fix(&str);
data = phpstr_data(&str, string, length);