X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_message_api.c;h=007437cfb30165eb4280c8a20df6534a3ae5df78;hp=67f99ae12e1f5cb38772bfcfed3779a6e15f1eca;hb=refs%2Fheads%2Fv1.7.x;hpb=34c551d43ab4fbfff88a81e545a43fbbf7a8a75d diff --git a/http_message_api.c b/http_message_api.c index 67f99ae..007437c 100644 --- a/http_message_api.c +++ b/http_message_api.c @@ -119,7 +119,11 @@ PHP_HTTP_API http_message *_http_message_init_env(http_message *message, http_me http_message_set_info(message, &inf); http_get_response_headers(&message->hdrs); +#ifdef PHP_OUTPUT_NEWAPI + if (SUCCESS == php_output_get_contents(&tval TSRMLS_CC)) { +#else if (SUCCESS == php_ob_get_buffer(&tval TSRMLS_CC)) { +#endif message->body.data = Z_STRVAL(tval); message->body.used = Z_STRLEN(tval); message->body.free = 1; /* "\0" */ @@ -281,47 +285,43 @@ static inline void _http_message_body_parse(http_message *msg, const char *messa #ifdef HTTP_HAVE_ZLIB /* check for compressed data */ - if ((c = http_message_header(msg, "Vary"))) { - zval_ptr_dtor(&c); - - if ((c = http_message_header(msg, "Content-Encoding"))) { - char *decoded = NULL; - size_t decoded_len = 0; - - if ( !strcasecmp(Z_STRVAL_P(c), "gzip") || - !strcasecmp(Z_STRVAL_P(c), "x-gzip") || - !strcasecmp(Z_STRVAL_P(c), "deflate")) { - http_encoding_inflate(PHPSTR_VAL(msg), PHPSTR_LEN(msg), &decoded, &decoded_len); - } - - if (decoded) { - zval *len, **original_len; - char *tmp; - int tmp_len; - - tmp_len = (int) spprintf(&tmp, 0, "%zu", decoded_len); - MAKE_STD_ZVAL(len); - ZVAL_STRINGL(len, tmp, tmp_len, 0); - - ZVAL_ADDREF(c); - zend_hash_update(&msg->hdrs, "X-Original-Content-Encoding", sizeof("X-Original-Content-Encoding"), (void *) &c, sizeof(zval *), NULL); - zend_hash_del(&msg->hdrs, "Content-Encoding", sizeof("Content-Encoding")); - if (SUCCESS == zend_hash_find(&msg->hdrs, "Content-Length", sizeof("Content-Length"), (void *) &original_len)) { - ZVAL_ADDREF(*original_len); - zend_hash_update(&msg->hdrs, "X-Original-Content-Length", sizeof("X-Original-Content-Length"), (void *) original_len, sizeof(zval *), NULL); - zend_hash_update(&msg->hdrs, "Content-Length", sizeof("Content-Length"), (void *) &len, sizeof(zval *), NULL); - } else { - zend_hash_update(&msg->hdrs, "Content-Length", sizeof("Content-Length"), (void *) &len, sizeof(zval *), NULL); - } - - phpstr_dtor(PHPSTR(msg)); - PHPSTR(msg)->data = decoded; - PHPSTR(msg)->used = decoded_len; - PHPSTR(msg)->free = 1; + if ((c = http_message_header(msg, "Content-Encoding"))) { + char *decoded = NULL; + size_t decoded_len = 0; + + if ( !strcasecmp(Z_STRVAL_P(c), "gzip") || + !strcasecmp(Z_STRVAL_P(c), "x-gzip") || + !strcasecmp(Z_STRVAL_P(c), "deflate")) { + http_encoding_inflate(PHPSTR_VAL(msg), PHPSTR_LEN(msg), &decoded, &decoded_len); + } + + if (decoded) { + zval *len, **original_len; + char *tmp; + int tmp_len; + + tmp_len = (int) spprintf(&tmp, 0, "%zu", decoded_len); + MAKE_STD_ZVAL(len); + ZVAL_STRINGL(len, tmp, tmp_len, 0); + + ZVAL_ADDREF(c); + zend_hash_update(&msg->hdrs, "X-Original-Content-Encoding", sizeof("X-Original-Content-Encoding"), (void *) &c, sizeof(zval *), NULL); + zend_hash_del(&msg->hdrs, "Content-Encoding", sizeof("Content-Encoding")); + if (SUCCESS == zend_hash_find(&msg->hdrs, "Content-Length", sizeof("Content-Length"), (void *) &original_len)) { + ZVAL_ADDREF(*original_len); + zend_hash_update(&msg->hdrs, "X-Original-Content-Length", sizeof("X-Original-Content-Length"), (void *) original_len, sizeof(zval *), NULL); + zend_hash_update(&msg->hdrs, "Content-Length", sizeof("Content-Length"), (void *) &len, sizeof(zval *), NULL); + } else { + zend_hash_update(&msg->hdrs, "Content-Length", sizeof("Content-Length"), (void *) &len, sizeof(zval *), NULL); } - - zval_ptr_dtor(&c); + + phpstr_dtor(PHPSTR(msg)); + PHPSTR(msg)->data = decoded; + PHPSTR(msg)->used = decoded_len; + PHPSTR(msg)->free = 1; } + + zval_ptr_dtor(&c); } #endif /* HTTP_HAVE_ZLIB */ }