-PHP_HTTP_API php_http_message_t *php_http_message_interconnect(php_http_message_t *m1, php_http_message_t *m2)
-{
- if (m1 && m2) {
- int i = 0, c1 = 0, c2 = 0;
- php_http_message_t *t1 = m1, *t2 = m2, *p1, *p2;
-
- php_http_message_count(c1, m1);
- php_http_message_count(c2, m2);
-
- while (i++ < (c1 - c2)) {
- t1 = t1->parent;
- }
- while (i++ <= c1) {
- p1 = t1->parent;
- p2 = t2->parent;
- t1->parent = t2;
- t2->parent = p1;
- t1 = p1;
- t2 = p2;
- }
- } else if (!m1 && m2) {
- m1 = m2;
- }
- return m1;
-}
-
-PHP_HTTP_API void php_http_message_to_struct(php_http_message_t *msg, zval *obj)
-{
- zval strct;
- zval *headers;
- char *version;
- TSRMLS_FETCH_FROM_CTX(msg->ts);
-
- INIT_PZVAL_ARRAY(&strct, HASH_OF(obj));
-
- add_assoc_long(&strct, "type", msg->type);
- spprintf(&version, 0 ,"%u.%u", msg->http.version.major, msg->http.version.minor);
- add_assoc_string_ex(&strct, ZEND_STRL("httpVersion"), version, 0);
- switch (msg->type)
- {
- case PHP_HTTP_RESPONSE:
- add_assoc_long(&strct, "responseCode", msg->http.info.response.code);
- add_assoc_string(&strct, "responseStatus", STR_PTR(msg->http.info.response.status), 1);
- break;
-
- case PHP_HTTP_REQUEST:
- add_assoc_string(&strct, "requestMethod", STR_PTR(msg->http.info.request.method), 1);
- add_assoc_string(&strct, "requestUrl", STR_PTR(msg->http.info.request.url), 1);
- break;
-
- case PHP_HTTP_NONE:
- /* avoid compiler warning */
- break;
- }
-
- MAKE_STD_ZVAL(headers);
- 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);
-
- add_assoc_stringl(&strct, "body", PHP_HTTP_BUFFER_VAL(msg), PHP_HTTP_BUFFER_LEN(msg), 1);
-
- if (msg->parent) {
- zval *parent;
-
- MAKE_STD_ZVAL(parent);
- if (Z_TYPE_P(obj) == IS_ARRAY) {
- array_init(parent);
- } else {
- object_init(parent);
- }
- add_assoc_zval(&strct, "parentMessage", parent);
- php_http_message_to_struct(msg->parent, parent);
- } else {
- add_assoc_null(&strct, "parentMessage");
- }
-}
-/*
-PHP_HTTP_API STATUS _http_message_send(http_message *message TSRMLS_DC)