X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_message_api.c;h=e399ed666a6e51a4c77bc41ae9f42151c72ea2ad;hp=42bae1a79f247e3c01c719d07faf5aa97b5fca34;hb=234dac3f03c6b7342bb70829bc9641268cab7156;hpb=0d925a2820b9d75b8e32c451fd400863e51e22fe diff --git a/http_message_api.c b/http_message_api.c index 42bae1a..e399ed6 100644 --- a/http_message_api.c +++ b/http_message_api.c @@ -129,7 +129,7 @@ PHP_HTTP_API void _http_message_set_type(http_message *message, http_message_typ PHP_HTTP_API http_message *_http_message_parse_ex(http_message *msg, const char *message, size_t message_length TSRMLS_DC) { - char *body = NULL, *cr, *lf; + const char *body = NULL; zend_bool free_msg = msg ? 0 : 1; if ((!message) || (message_length < HTTP_MSG_MIN_SIZE)) { @@ -146,11 +146,10 @@ PHP_HTTP_API http_message *_http_message_parse_ex(http_message *msg, const char } /* header parsing stops at (CR)LF (CR)LF */ - if (body = strstr(message, HTTP_CRLF HTTP_CRLF)) { + if (body = http_locate_body(message)) { zval *c; const char *continue_at = NULL; - body += lenof(HTTP_CRLF HTTP_CRLF); /* message has content-length header */ if (c = http_message_header(msg, "Content-Length")) { long len = atol(Z_STRVAL_P(c)); @@ -335,7 +334,6 @@ PHP_HTTP_API void _http_message_tostruct_recursive(http_message *msg, zval *obj array_init(headers); zend_hash_copy(Z_ARRVAL_P(headers), &msg->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); add_assoc_zval(&strct, "headers", headers); - zval_ptr_dtor(&headers); add_assoc_stringl(&strct, "body", PHPSTR_VAL(msg), PHPSTR_LEN(msg), 1); @@ -354,8 +352,6 @@ PHP_HTTP_API void _http_message_tostruct_recursive(http_message *msg, zval *obj } else { add_assoc_null(&strct, "parentMessage"); } - http_message_dtor(msg); - efree(msg); } PHP_HTTP_API STATUS _http_message_send(http_message *message TSRMLS_DC)