X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_message_api.c;h=86ab323366facbdf8383d2123ca6ce87a3b41be1;hb=153ce526e9d8e81ff03388cf536babab704c76f5;hp=a0f5e59ada74c8a79fa40d0ef693dd0b2eb7b117;hpb=16ea91ddd08d15dd9b7206229fec6158f212adaf;p=m6w6%2Fext-http diff --git a/http_message_api.c b/http_message_api.c index a0f5e59..86ab323 100644 --- a/http_message_api.c +++ b/http_message_api.c @@ -18,8 +18,8 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif - #include "php.h" + #include "php_http.h" #include "php_http_std_defs.h" #include "php_http_api.h" @@ -190,7 +190,7 @@ PHP_HTTP_API http_message *_http_message_parse_ex(http_message *msg, const char zval *len; char *tmp; - spprintf(&tmp, 0, "%lu", decoded_len); + spprintf(&tmp, 0, "%lu", (ulong) decoded_len); MAKE_STD_ZVAL(len); ZVAL_STRING(len, tmp, 0); @@ -213,8 +213,10 @@ PHP_HTTP_API http_message *_http_message_parse_ex(http_message *msg, const char } else /* no headers that indicate content length */ - if (1) { + if (HTTP_MSG_TYPE(RESPONSE, msg)) { phpstr_from_string_ex(PHPSTR(msg), body, message + message_length - body); + } else { + continue_at = body; } /* check for following messages */ @@ -412,6 +414,21 @@ PHP_HTTP_API STATUS _http_message_send(http_message *message TSRMLS_DC) return rs; } +PHP_HTTP_API http_message *_http_message_dup(http_message *msg TSRMLS_DC) +{ + /* + * TODO: unroll + */ + http_message *new; + char *serialized_data; + size_t serialized_length; + + http_message_serialize(msg, &serialized_data, &serialized_length); + new = http_message_parse(serialized_data, serialized_length); + efree(serialized_data); + return new; +} + PHP_HTTP_API void _http_message_dtor(http_message *message) { if (message) {