- /* we need to act like a zipper, as we'll receive
- * the requests and the responses in separate chains
- * for redirects
- */
- http_message *response = msg, *request = http_message_parse(PHPSTR_VAL(&obj->request->conv.request), PHPSTR_LEN(&obj->request->conv.request));
- http_message *free_msg = request;
-
- do {
- char *message;
- size_t msglen;
-
- http_message_tostring(response, &message, &msglen);
- phpstr_append(&obj->history, message, msglen);
- efree(message);
-
- http_message_tostring(request, &message, &msglen);
- phpstr_append(&obj->history, message, msglen);
- efree(message);
-
- } while ((response = response->parent) && (request = request->parent));
-
- http_message_free(&free_msg);
- phpstr_fix(&obj->history);
+ zval *hist, *history = GET_PROP(history);
+ http_message *response = http_message_parse(PHPSTR_VAL(&obj->request->conv.response), PHPSTR_LEN(&obj->request->conv.response));
+ http_message *request = http_message_parse(PHPSTR_VAL(&obj->request->conv.request), PHPSTR_LEN(&obj->request->conv.request));
+
+ MAKE_STD_ZVAL(hist);
+ ZVAL_OBJVAL(hist, http_message_object_new_ex(http_message_object_ce, http_message_interconnect(response, request), NULL), 0);
+ if (Z_TYPE_P(history) == IS_OBJECT) {
+ http_message_object_prepend(hist, history);
+ }
+ SET_PROP(history, hist);
+ zval_ptr_dtor(&hist);