+static php_http_message_t *php_http_curlm_responseparser(php_http_client_curl_handler_t *h TSRMLS_DC)
+{
+ php_http_message_t *response = NULL;
+ php_http_header_parser_t parser;
+
+ response = php_http_message_init(NULL, 0, h->response.body TSRMLS_CC);
+ php_http_header_parser_init(&parser TSRMLS_CC);
+ php_http_header_parser_parse(&parser, &h->response.headers, PHP_HTTP_HEADER_PARSER_CLEANUP, &response->hdrs, (php_http_info_callback_t) php_http_message_info_callback, (void *) &response);
+ php_http_header_parser_dtor(&parser);
+
+ /* move body to right message */
+ if (response->body != h->response.body) {
+ php_http_message_t *ptr = response;
+
+ while (ptr->parent) {
+ ptr = ptr->parent;
+ }
+ response->body = ptr->body;
+ ptr->body = NULL;
+ }
+ php_http_message_body_addref(h->response.body);
+
+ php_http_message_update_headers(response);
+
+ return response;
+}
+