add php_http_message_zip(): merge request/response messages for history
authorMichael Wallner <mike@php.net>
Mon, 30 Jul 2012 18:31:46 +0000 (18:31 +0000)
committerMichael Wallner <mike@php.net>
Mon, 30 Jul 2012 18:31:46 +0000 (18:31 +0000)
php_http_message.c
php_http_message.h

index 34d9ed8..04e8706 100644 (file)
@@ -462,6 +462,24 @@ PHP_HTTP_API php_http_message_t *php_http_message_reverse(php_http_message_t *ms
        return msg;
 }
 
+PHP_HTTP_API php_http_message_t *php_http_message_zip(php_http_message_t *one, php_http_message_t *two)
+{
+       php_http_message_t *dst = php_http_message_copy(one, NULL), *src = php_http_message_copy(two, NULL), *tmp_dst, *tmp_src, *ret = dst;
+
+       while(dst && src) {
+               tmp_dst = dst->parent;
+               tmp_src = src->parent;
+               dst->parent = src;
+               if (tmp_dst) {
+                       src->parent = tmp_dst;
+               }
+               src = tmp_src;
+               dst = tmp_dst;
+       }
+
+       return ret;
+}
+
 PHP_HTTP_API php_http_message_t *php_http_message_copy_ex(php_http_message_t *from, php_http_message_t *to, zend_bool parents)
 {
        php_http_message_t *temp, *copy = NULL;
index fb991f5..766c0b4 100644 (file)
@@ -61,6 +61,7 @@ PHP_HTTP_API void php_http_message_to_callback(php_http_message_t *msg, php_http
 
 PHP_HTTP_API void php_http_message_serialize(php_http_message_t *message, char **string, size_t *length);
 PHP_HTTP_API php_http_message_t *php_http_message_reverse(php_http_message_t *msg);
+PHP_HTTP_API php_http_message_t *php_http_message_zip(php_http_message_t *one, php_http_message_t *two);
 
 #define php_http_message_count(c, m) \
 { \