+ zval *headers, *message,
+ *resp = GET_PROP(obj, responseData),
+ *info = GET_PROP(obj, responseInfo),
+ *hist = GET_PROP(obj, recordHistory);
+
+ /* should we record history? */
+ if (Z_TYPE_P(hist) != IS_BOOL) {
+ convert_to_boolean_ex(&hist);
+ }
+ if (Z_LVAL_P(hist)) {
+ /* 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), PHPSTR_LEN(&obj->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);
+ }