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)) {
}
/* 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));
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);
} else {
add_assoc_null(&strct, "parentMessage");
}
- http_message_dtor(msg);
- efree(msg);
}
PHP_HTTP_API STATUS _http_message_send(http_message *message TSRMLS_DC)