branch off v1 as R_1_7 v1.7.x
authorMichael Wallner <mike@php.net>
Thu, 21 Nov 2013 09:20:53 +0000 (09:20 +0000)
committerMichael Wallner <mike@php.net>
Thu, 21 Nov 2013 09:20:53 +0000 (09:20 +0000)
26 files changed:
http_api.c
http_cache_api.c
http_deflatestream_object.c
http_encoding_api.c
http_inflatestream_object.c
http_info_api.c
http_message_api.c
http_message_object.c
http_querystring_object.c
http_request_api.c
http_request_info.c
http_request_method_api.c
http_request_object.c
http_requestdatashare_object.c
http_requestpool_object.c
http_response_object.c
http_send_api.c
missing.h
package.xml
php_http.h
php_http_api.h
php_http_std_defs.h
scripts/gen_curlinfo.php
tests/HttpRequest_007.phpt
tests/bug_15800.phpt
tests/request_gzip.phpt

index aca90e669f5adeed209212cb1fbbc86bb34827e1..6b01a3bce7d43dda465fd49e8f98de828e76c2c1 100644 (file)
@@ -252,10 +252,14 @@ STATUS _http_exit_ex(int status, char *header, char *body, zend_bool send_header
                STR_FREE(body);
                return FAILURE;
        }
-       
-       if (!OG(ob_lock)) {
+
+#ifndef PHP_OUTPUT_NEWAPI
+       if (!OG(ob_lock) &&
+               !php_ob_handler_used("zlib output compression" TSRMLS_CC) && !php_ob_handler_used("ob_gzhandler" TSRMLS_CC)) {
                php_end_ob_buffers(0 TSRMLS_CC);
        }
+#endif
+
        if ((SUCCESS == sapi_send_headers(TSRMLS_C)) && body) {
                PHPWRITE(body, strlen(body));
        }
@@ -278,7 +282,11 @@ STATUS _http_exit_ex(int status, char *header, char *body, zend_bool send_header
        if (HTTP_G->force_exit) {
                zend_bailout();
        } else {
+#ifdef PHP_OUTPUT_NEWAPI
+               php_output_start_devnull(TSRMLS_C);
+#else
                php_ob_set_internal_handler(http_ob_blackhole, 4096, "blackhole", 0 TSRMLS_CC);
+#endif
        }
        
        return SUCCESS;
@@ -356,11 +364,12 @@ PHP_HTTP_API STATUS _http_get_request_body_ex(char **body, size_t *length, zend_
                HTTP_G->read_post_data = 1;
                
                while (0 < (len = sapi_module.read_post(buf, 4096 TSRMLS_CC))) {
+                       SG(read_post_bytes) += len;
                        *body = erealloc(*body, *length + len + 1);
                        memcpy(*body + *length, buf, len);
                        *length += len;
                        (*body)[*length] = '\0';
-                       if (len < (int) sizeof(buf)) {
+                       if (len < 4096) {
                                break;
                        }
                }
@@ -401,8 +410,9 @@ PHP_HTTP_API php_stream *_http_get_request_body_stream(TSRMLS_D)
                        int len;
                        
                        while (0 < (len = sapi_module.read_post(buf, 4096 TSRMLS_CC))) {
+                               SG(read_post_bytes) += len;
                                php_stream_write(s, buf, len);
-                               if (len < (int) sizeof(buf)) {
+                               if (len < 4096) {
                                        break;
                                }
                        }
index 4cc07b996da0e6fdb1d984b77bd13bf0b37af623..b6bc23714bd292882716ae66692118290b66095e 100644 (file)
@@ -182,13 +182,24 @@ PHP_HTTP_API STATUS _http_cache_etag(const char *etag, size_t etag_len,
 PHP_HTTP_API STATUS _http_start_ob_etaghandler(TSRMLS_D)
 {
        /* already running? */
+#ifdef PHP_OUTPUT_NEWAPI
+    STATUS rv;
+
+    if (php_output_handler_conflict(ZEND_STRL("ob_etaghandler"), ZEND_STRL("ob_etaghandler") TSRMLS_CC)) {
+        return FAILURE;
+    }
+#else
        if (php_ob_handler_used("ob_etaghandler" TSRMLS_CC)) {
                http_error(HE_WARNING, HTTP_E_RUNTIME, "ob_etaghandler can only be used once");
                return FAILURE;
        }
-       
+#endif
        HTTP_G->etag.started = 1;
+#ifdef PHP_OUTPUT_NEWAPI
+    return php_output_start_internal(ZEND_STRL("ob_etaghandler"), _http_ob_etaghandler, HTTP_G->send.buffer_size, 0 TSRMLS_CC);
+#else
        return php_start_ob_buffer_named("ob_etaghandler", HTTP_G->send.buffer_size, 0 TSRMLS_CC);
+#endif
 }
 
 PHP_HTTP_API zend_bool _http_interrupt_ob_etaghandler(TSRMLS_D)
index c3c80458685d9ce880d961b789cf8d450163be18..6b0d472123af47888f171f098e58a4bbb2f5d071 100644 (file)
@@ -107,9 +107,14 @@ zend_object_value _http_deflatestream_object_new_ex(zend_class_entry *ce, http_e
                o->stream = s;
        }
 
+#ifdef ZEND_ENGINE_2_4
+       zend_object_std_init(o, ce TSRMLS_CC);
+       object_properties_init(o, ce);
+#else
        ALLOC_HASHTABLE(OBJ_PROP(o));
        zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), NULL, ZVAL_PTR_DTOR, 0);
        zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
+#endif
 
        ov.handle = putObject(http_deflatestream_object, o);
        ov.handlers = &http_deflatestream_object_handlers;
index 8ce0280ca22c5e0911d2e5115674f972b47ba27f..1d9b9163a31af614fda99c992818fe4ef40ed7a3 100644 (file)
@@ -46,10 +46,18 @@ PHP_MINIT_FUNCTION(http_encoding)
 PHP_RINIT_FUNCTION(http_encoding)
 {
        if (HTTP_G->send.inflate.start_auto) {
+#ifdef PHP_OUTPUT_NEWAPI
+               php_output_start_internal(ZEND_STRL("http inflate"), _http_ob_inflatehandler, HTTP_INFLATE_BUFFER_SIZE, 0 TSRMLS_CC);
+#else
                php_ob_set_internal_handler(_http_ob_inflatehandler, HTTP_INFLATE_BUFFER_SIZE, "http inflate", 0 TSRMLS_CC);
+#endif
        }
        if (HTTP_G->send.deflate.start_auto) {
+#ifdef PHP_OUTPUT_NEWAPI
+               php_output_start_internal(ZEND_STRL("http deflate"), _http_ob_deflatehandler, HTTP_DEFLATE_BUFFER_SIZE, 0 TSRMLS_CC);
+#else
                php_ob_set_internal_handler(_http_ob_deflatehandler, HTTP_DEFLATE_BUFFER_SIZE, "http deflate", 0 TSRMLS_CC);
+#endif
        }
        return SUCCESS;
 }
@@ -161,10 +169,18 @@ PHP_HTTP_API const char *_http_encoding_dechunk(const char *encoded, size_t enco
 PHP_HTTP_API int _http_encoding_response_start(size_t content_length, zend_bool ignore_http_ohandler TSRMLS_DC)
 {
        int response = HTTP_G->send.deflate.response;
+#ifdef PHP_OUTPUT_NEWAPI
+       int ohandler = php_output_handler_started(ZEND_STRL("ob_gzhandler") TSRMLS_CC) || php_output_handler_started(ZEND_STRL("zlib output compression") TSRMLS_CC);
+#else
        int ohandler = php_ob_handler_used("ob_gzhandler" TSRMLS_CC) || php_ob_handler_used("zlib output compression" TSRMLS_CC);
+#endif
        
        if (!ohandler && !ignore_http_ohandler) {
+#ifdef PHP_OUTPUT_NEWAPI
+               ohandler = php_output_handler_started(ZEND_STRL("ob_defaltehandler") TSRMLS_CC) || php_output_handler_started(ZEND_STRL("http deflate") TSRMLS_CC);
+#else
                ohandler = php_ob_handler_used("ob_deflatehandler" TSRMLS_CC) || php_ob_handler_used("http deflate" TSRMLS_CC);
+#endif
        }
        
        if (response && !ohandler) {
@@ -347,10 +363,6 @@ retry_raw_inflate:
                                }
                }
                inflateEnd(&Z);
-
-               if (decoded_len && *decoded) {
-                       efree(*decoded);
-               }
        }
        
        http_error_ex(HE_WARNING, HTTP_E_ENCODING, "Could not inflate data: %s", zError(status));
index 53e5571e110768b56c57e5caa89d17c56b95fdeb..3340e4c446cf517d9e1166a906821b05c9c5c5ec 100644 (file)
@@ -96,9 +96,14 @@ zend_object_value _http_inflatestream_object_new_ex(zend_class_entry *ce, http_e
                o->stream = s;
        }
 
+#ifdef ZEND_ENGINE_2_4
+       zend_object_std_init(o, ce TSRMLS_CC);
+       object_properties_init(o, ce);
+#else
        ALLOC_HASHTABLE(OBJ_PROP(o));
        zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), NULL, ZVAL_PTR_DTOR, 0);
        zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
+#endif
 
        ov.handle = putObject(http_inflatestream_object, o);
        ov.handlers = &http_inflatestream_object_handlers;
index d3cab940d2d5454e4262723c5c8bb27530159cce..358b5bf6c894b7fc0edac8775e7e8424d06e668b 100644 (file)
@@ -31,7 +31,9 @@ PHP_HTTP_API void _http_info_default_callback(void **nothing, HashTable **header
                
                case IS_HTTP_RESPONSE:
                        add_assoc_long(&array, "Response Code", (long) HTTP_INFO(info).response.code);
-                       add_assoc_string(&array, "Response Status", HTTP_INFO(info).response.status, 1);
+                       if (HTTP_INFO(info).response.status) {
+                               add_assoc_string(&array, "Response Status", HTTP_INFO(info).response.status, 1);
+                       }
                        break;
        }
 }
index 66bc50823498f7d45f92a5474897f9145faefb6d..007437cfb30165eb4280c8a20df6534a3ae5df78 100644 (file)
@@ -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" */
index a5b2ca82616d38f78bf94e3dba62a6c65df6bc4d..0856aefc66afd28b7447f2524e51c30ea4d61387 100644 (file)
@@ -150,7 +150,7 @@ static zval *_http_message_object_read_prop(zval *object, zval *member, int type
 #define http_message_object_write_prop _http_message_object_write_prop
 static void _http_message_object_write_prop(zval *object, zval *member, zval *value ZEND_LITERAL_KEY_DC TSRMLS_DC);
 #define http_message_object_get_prop_ptr _http_message_object_get_prop_ptr
-static zval **_http_message_object_get_prop_ptr(zval *object, zval *member ZEND_LITERAL_KEY_DC TSRMLS_DC);
+static zval **_http_message_object_get_prop_ptr(zval *object, zval *member ZEND_GET_PPTR_TYPE_DC ZEND_LITERAL_KEY_DC TSRMLS_DC);
 #define http_message_object_get_props _http_message_object_get_props
 static HashTable *_http_message_object_get_props(zval *object TSRMLS_DC);
 
@@ -513,9 +513,15 @@ zend_object_value _http_message_object_new_ex(zend_class_entry *ce, http_message
                }
        }
 
+       
+#ifdef ZEND_ENGINE_2_4
+       zend_object_std_init(o, ce TSRMLS_CC);
+       object_properties_init(o, ce);
+#else
        ALLOC_HASHTABLE(OBJ_PROP(o));
        zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), NULL, ZVAL_PTR_DTOR, 0);
        zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
+#endif
 
        ov.handle = putObject(http_message_object, o);
        ov.handlers = &http_message_object_handlers;
@@ -558,7 +564,7 @@ void _http_message_object_free(zend_object *object TSRMLS_DC)
        freeObject(o);
 }
 
-static zval **_http_message_object_get_prop_ptr(zval *object, zval *member ZEND_LITERAL_KEY_DC TSRMLS_DC) {
+static zval **_http_message_object_get_prop_ptr(zval *object, zval *member ZEND_GET_PPTR_TYPE_DC ZEND_LITERAL_KEY_DC TSRMLS_DC) {
        getObjectEx(http_message_object, obj, object);
        http_message_object_prophandler *handler;
        
@@ -567,7 +573,7 @@ static zval **_http_message_object_get_prop_ptr(zval *object, zval *member ZEND_
                return NULL;
        }
 
-       return zend_get_std_object_handlers()->get_property_ptr_ptr(object, member ZEND_LITERAL_KEY_CC TSRMLS_CC);
+       return zend_get_std_object_handlers()->get_property_ptr_ptr(object, member ZEND_GET_PPTR_TYPE_CC ZEND_LITERAL_KEY_CC TSRMLS_CC);
 }
 
 static zval *_http_message_object_read_prop(zval *object, zval *member, int type ZEND_LITERAL_KEY_DC TSRMLS_DC)
@@ -617,9 +623,12 @@ static HashTable *_http_message_object_get_props(zval *object TSRMLS_DC)
        zval *headers;
        getObjectEx(http_message_object, obj, object);
        http_message *msg = obj->message;
-       HashTable *props = OBJ_PROP(obj);
        zval array, *parent;
-       
+#ifdef ZEND_ENGINE_2_4
+       HashTable *props = zend_get_std_object_handlers()->get_properties(object TSRMLS_CC);
+#else
+       HashTable *props = OBJ_PROP(obj);
+#endif
        INIT_ZARR(array, props);
 
 #define ASSOC_PROP(array, ptype, name, val) \
@@ -681,7 +690,7 @@ static HashTable *_http_message_object_get_props(zval *object TSRMLS_DC)
        }
        ASSOC_PROP(array, zval, "parentMessage", parent);
 
-       return OBJ_PROP(obj);
+       return props;
 }
 
 /* ### USERLAND ### */
@@ -1000,7 +1009,7 @@ PHP_METHOD(HttpMessage, setResponseStatus)
        
        HTTP_CHECK_MESSAGE_TYPE_RESPONSE(obj->message, RETURN_FALSE);
        
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &status, &status_len)) {
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &status, &status_len)) {
                RETURN_FALSE;
        }
        STR_SET(obj->message->http.info.response.status, estrndup(status, status_len));
index 0e7b2ac7127bcc0275efddc0677ebaa0a768aca3..4c82edabcff853fb0dfa9fe14886c9e0991b662f 100644 (file)
@@ -191,9 +191,14 @@ zend_object_value _http_querystring_object_new_ex(zend_class_entry *ce, void *no
                *ptr = o;
        }
 
+#ifdef ZEND_ENGINE_2_4
+       zend_object_std_init(o, ce TSRMLS_CC);
+       object_properties_init(o, ce);
+#else
        ALLOC_HASHTABLE(OBJ_PROP(o));
        zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), NULL, ZVAL_PTR_DTOR, 0);
        zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
+#endif
 
        ov.handle = putObject(http_querystring_object, o);
        ov.handlers = &http_querystring_object_handlers;
index d328161e13eca231b8dd48a601290d93e695f800..b6e40344c27001aeba102f149c63ea4b164af5a2 100644 (file)
@@ -615,7 +615,10 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti
        TSRMLS_FETCH_FROM_CTX(request->tsrm_ls);
        
        HTTP_CHECK_CURL_INIT(request->ch, http_curl_init(request), return FAILURE);
-       
+
+       if (!request->url) {
+               return FAILURE;
+       }
        if (!(storage = http_request_storage_get(request->ch))) {
                return FAILURE;
        }
@@ -869,12 +872,29 @@ PHP_HTTP_API STATUS _http_request_prepare(http_request *request, HashTable *opti
        }
        /* etag */
        if ((zoption = http_request_option(request, options, "etag", IS_STRING)) && Z_STRLEN_P(zoption)) {
-               zend_bool is_quoted = !((Z_STRVAL_P(zoption)[0] != '"') || (Z_STRVAL_P(zoption)[Z_STRLEN_P(zoption)-1] != '"'));
+               zend_bool is_quoted;
                phpstr header;
-               
+
                phpstr_init(&header);
-               phpstr_appendf(&header, is_quoted?"%s: %s":"%s: \"%s\"", range_req?"If-Match":"If-None-Match", Z_STRVAL_P(zoption));
+               phpstr_appendf(&header, "%s: ", range_req?"If-Match":"If-None-Match");
+               if ((Z_STRVAL_P(zoption)[0] == '"') && (Z_STRVAL_P(zoption)[Z_STRLEN_P(zoption)-1] == '"')) {
+                       /* properly quoted etag */
+                       phpstr_append(&header, Z_STRVAL_P(zoption), Z_STRLEN_P(zoption));
+               } else if ((Z_STRVAL_P(zoption)[0] == 'W') && (Z_STRVAL_P(zoption)[1] == '/')) {
+                       /* weak etag */
+                       if ((Z_STRLEN_P(zoption) > 3) && (Z_STRVAL_P(zoption)[2] == '"') && (Z_STRVAL_P(zoption)[Z_STRLEN_P(zoption)-1] == '"')) {
+                               /* quoted */
+                               phpstr_append(&header, Z_STRVAL_P(zoption), Z_STRLEN_P(zoption));
+                       } else {
+                               /* unquoted */
+                               phpstr_appendf(&header, "W/\"%s\"", Z_STRVAL_P(zoption) + 2);
+                       }
+               } else {
+                       /* assume unquoted etag */
+                       phpstr_appendf(&header, "\"%s\"", Z_STRVAL_P(zoption));
+               }
                phpstr_fix(&header);
+
                request->_cache.headers = curl_slist_append(request->_cache.headers, PHPSTR_VAL(&header));
                phpstr_dtor(&header);
        }
index 809512ade05d1ed6510a4f66679513b38c94fc37..b817841e84174297544f6d89621b758f812b0352 100644 (file)
@@ -148,6 +148,21 @@ PHP_HTTP_API void _http_request_info(http_request *request, HashTable *info)
                add_assoc_long_ex(&array, "condition_unmet", sizeof("condition_unmet"), l);
        }
 #endif
+#if HTTP_CURL_VERSION(7,21,0)
+       if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_PRIMARY_PORT, &l)) {
+               add_assoc_long_ex(&array, "primary_port", sizeof("primary_port"), l);
+       }
+#endif
+#if HTTP_CURL_VERSION(7,21,0)
+       if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_LOCAL_IP, &c)) {
+               add_assoc_string_ex(&array, "local_ip", sizeof("local_ip"), c ? c : "", 1);
+       }
+#endif
+#if HTTP_CURL_VERSION(7,21,0)
+       if (CURLE_OK == curl_easy_getinfo(request->ch, CURLINFO_LOCAL_PORT, &l)) {
+               add_assoc_long_ex(&array, "local_port", sizeof("local_port"), l);
+       }
+#endif
 /* END */
 #if HTTP_CURL_VERSION(7,19,1) && defined(HTTP_HAVE_OPENSSL)
        {
index 5be28c17add665c621eac813d2e7fccc323bf1dd..2f99a9152259ccef5032d15ab2513b7a4e729216 100644 (file)
@@ -214,7 +214,8 @@ static STATUS _http_request_method_cncl_ex(const char *method_name, int method_n
        for (i = 0; i < method_name_len; ++i) {
                switch (method_name[i]) {
                        case '-':
-                               cncl[i] = '-';
+                       case '_':
+                               cncl[i] = method_name[i];
                                break;
                        
                        default:
index 8ea09b0f0af7a2528a1dbf01957b206dfd8f5175..f4f27cf0718892e48c918e6b5685c3ee28d1165e 100644 (file)
@@ -492,9 +492,14 @@ zend_object_value _http_request_object_new_ex(zend_class_entry *ce, CURL *ch, ht
                *ptr = o;
        }
 
+#ifdef ZEND_ENGINE_2_4
+       zend_object_std_init(o, ce TSRMLS_CC);
+       object_properties_init(o, ce);
+#else
        ALLOC_HASHTABLE(OBJ_PROP(o));
        zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), NULL, ZVAL_PTR_DTOR, 0);
        zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
+#endif
 
        ov.handle = putObject(http_request_object, o);
        ov.handlers = &http_request_object_handlers;
@@ -678,7 +683,7 @@ STATUS _http_request_object_requesthandler(http_request_object *obj, zval *this_
                        
                        if (    (Z_TYPE_P(options) != IS_ARRAY)
                                ||      (SUCCESS != zend_hash_find(Z_ARRVAL_P(options), "onprogress", sizeof("onprogress"), (void *) &entry)
-                               ||      (!IS_CALLABLE(*entry, 0, NULL)))) {
+                               ||      (!HTTP_IS_CALLABLE(*entry, 0, NULL)))) {
                                MAKE_STD_ZVAL(pcb);
                                array_init(pcb);
                                ZVAL_ADDREF(getThis());
@@ -783,8 +788,12 @@ STATUS _http_request_object_responsehandler(http_request_object *obj, zval *this
        
        return ret;
 }
-
-static int apply_pretty_key(void *pDest, int num_args, va_list args, zend_hash_key *hash_key)
+#ifdef ZEND_ENGINE_2_4
+#      define APK_DC TSRMLS_DC
+#else
+#      define APK_DC
+#endif
+static int apply_pretty_key(void *pDest APK_DC, int num_args, va_list args, zend_hash_key *hash_key)
 {
        if (hash_key->arKey && hash_key->nKeyLength > 1) {
                hash_key->h = zend_hash_func(pretty_key(hash_key->arKey, hash_key->nKeyLength - 1, 1, 0), hash_key->nKeyLength);
index 8eacef859dda72404903fc3f0af48f60e92f0f1f..eed7d6b8ef125ecfb08c36e2a2f70c0a52b02d10 100644 (file)
@@ -125,9 +125,14 @@ zend_object_value _http_requestdatashare_object_new_ex(zend_class_entry *ce, htt
                *ptr = o;
        }
 
+#ifdef ZEND_ENGINE_2_4
+       zend_object_std_init(o, ce TSRMLS_CC);
+       object_properties_init(o, ce);
+#else
        ALLOC_HASHTABLE(OBJ_PROP(o));
        zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), NULL, ZVAL_PTR_DTOR, 0);
        zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
+#endif
 
        ov.handle = putObject(http_requestdatashare_object, o);
        ov.handlers = &http_requestdatashare_object_handlers;
@@ -147,7 +152,13 @@ void _http_requestdatashare_object_free(zend_object *object TSRMLS_DC)
 
 static zval *_http_requestdatashare_object_read_prop(zval *object, zval *member, int type ZEND_LITERAL_KEY_DC TSRMLS_DC)
 {
-       if (type == BP_VAR_W && zend_hash_exists(&THIS_CE->default_properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1)) {
+       if (type == BP_VAR_W && 
+#ifdef ZEND_ENGINE_2_4 
+       zend_hash_exists(&THIS_CE->properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1)
+#else
+       zend_hash_exists(&THIS_CE->default_properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1)
+#endif
+       ) {
                zend_error(E_ERROR, "Cannot access HttpRequestDataShare default properties by reference or array key/index");
                return NULL;
        }
@@ -157,7 +168,13 @@ static zval *_http_requestdatashare_object_read_prop(zval *object, zval *member,
 
 static void _http_requestdatashare_object_write_prop(zval *object, zval *member, zval *value ZEND_LITERAL_KEY_DC TSRMLS_DC)
 {
-       if (zend_hash_exists(&THIS_CE->default_properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1)) {
+       if (
+#ifdef ZEND_ENGINE_2_4
+       zend_hash_exists(&THIS_CE->properties_info, Z_STRVAL_P(member), Z_STRLEN_P(member)+1)
+#else
+       zend_hash_exists(&THIS_CE->default_properties, Z_STRVAL_P(member), Z_STRLEN_P(member)+1)
+#endif
+       ) {
                int status;
                getObjectEx(http_requestdatashare_object, obj, object);
                
index 653843a12381646071aa195dd39dc47022484ec2..a0f219cb8429094abeb9f6b97da1f92c1f63ecda 100644 (file)
@@ -129,9 +129,14 @@ zend_object_value _http_requestpool_object_new(zend_class_entry *ce TSRMLS_DC)
 
        http_request_pool_init(&o->pool);
 
+#ifdef ZEND_ENGINE_2_4
+       zend_object_std_init(o, ce TSRMLS_CC);
+       object_properties_init(o, ce);
+#else
        ALLOC_HASHTABLE(OBJ_PROP(o));
        zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), NULL, ZVAL_PTR_DTOR, 0);
        zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
+#endif
 
        ov.handle = putObject(http_requestpool_object, o);
        ov.handlers = &http_requestpool_object_handlers;
index cfa509566fcd7141c166b2500f517f50d2c104e2..c8d45cca997de2f9327f51a0f78ec5681b4678cb 100644 (file)
@@ -745,7 +745,11 @@ PHP_METHOD(HttpResponse, send)
                zval *zetag, *the_data;
 
                MAKE_STD_ZVAL(the_data);
+#ifdef PHP_OUTPUT_NEWAPI
+               php_output_get_contents(the_data TSRMLS_CC);
+#else
                php_ob_get_buffer(the_data TSRMLS_CC);
+#endif
                zend_update_static_property(THIS_CE, ZEND_STRS("data")-1, the_data TSRMLS_CC);
                ZVAL_LONG(*zend_std_get_static_property(THIS_CE, ZEND_STRS("mode")-1, 0 ZEND_LITERAL_NIL_CC TSRMLS_CC), SEND_DATA);
 
@@ -767,7 +771,11 @@ PHP_METHOD(HttpResponse, send)
                /* interrupt on-the-fly etag generation */
                HTTP_G->etag.started = 0;
                /* discard previous output buffers */
+#ifdef PHP_OUTPUT_NEWAPI
+               php_output_discard_all(TSRMLS_C);
+#else
                php_end_ob_buffers(0 TSRMLS_CC);
+#endif
        }
 
        /* caching */
@@ -879,9 +887,13 @@ PHP_METHOD(HttpResponse, capture)
        HTTP_CHECK_HEADERS_SENT(RETURN_FALSE);
 
        zend_update_static_property_long(THIS_CE, ZEND_STRS("catch")-1, 1 TSRMLS_CC);
-
+#ifdef PHP_OUTPUT_NEWAPI
+       php_output_discard_all(TSRMLS_C);
+       php_output_start_default(TSRMLS_C);
+#else
        php_end_ob_buffers(0 TSRMLS_CC);
        php_start_ob_buffer(NULL, 0, 0 TSRMLS_CC);
+#endif
 
        /* register shutdown function */
        {
index 319c7d6285a8c9da350e12a509c0bf8844a3f06f..1082e296460651f289dae088a558421e7505bf8b 100644 (file)
@@ -34,12 +34,16 @@ static inline void _http_flush(void *nothing, const char *data, size_t data_len
        /*      we really only need to flush when throttling is enabled,
                because we push the data as fast as possible anyway if not */
        if (HTTP_G->send.throttle_delay >= HTTP_DIFFSEC) {
+#if defined(PHP_VERSION_ID) && (PHP_VERSION_ID >= 50399)
+               php_output_end_all(TSRMLS_C);
+#else
                if (OG(ob_nesting_level)) {
                        php_end_ob_buffer(1, 1 TSRMLS_CC);
                }
                if (!OG(implicit_flush)) {
                        sapi_flush(TSRMLS_C);
                }
+#endif
                http_sleep(HTTP_G->send.throttle_delay);
        }
 }
index de4f0831163e92ef20d115991225dfec945c6d68..3efe1a2b2873b163188f9951b80a98b9ebdf4841 100644 (file)
--- a/missing.h
+++ b/missing.h
 
 #include "php_version.h"
 
+#if ZEND_MODULE_API_NO >= 20100409
+#define ZEND_ENGINE_2_4
+#endif
+
+#if defined(PHP_VERSION_ID) && (PHP_VERSION_ID >= 50500)
+#      define ZEND_GET_PPTR_TYPE_DC , int type
+#      define ZEND_GET_PPTR_TYPE_CC , type
+#else
+#      define ZEND_GET_PPTR_TYPE_DC
+#      define ZEND_GET_PPTR_TYPE_CC
+#endif
+
 #if defined(PHP_VERSION_ID) && (PHP_VERSION_ID >= 50399)
 #      define ZEND_LITERAL_KEY_DC , const zend_literal *_zend_literal_key
 #      define ZEND_LITERAL_KEY_CC , _zend_literal_key
@@ -66,7 +78,7 @@
 #      define HTTP_ZAPI_CONST_CAST(t) (const t)
 #      define GLOBAL_ERROR_HANDLING EG(error_handling)
 #      define GLOBAL_EXCEPTION_CLASS EG(exception_class)
-#      define IS_CALLABLE(cb_zv, flags, cb_sp) zend_is_callable((cb_zv), (flags), (cb_sp) TSRMLS_CC)
+#      define HTTP_IS_CALLABLE(cb_zv, flags, cb_sp) zend_is_callable((cb_zv), (flags), (cb_sp) TSRMLS_CC)
 #      define HTTP_STATIC_ARG_INFO
 #else
 #      define HTTP_ZAPI_HASH_TSRMLS_CC
@@ -74,7 +86,7 @@
 #      define HTTP_ZAPI_CONST_CAST(t) (t)
 #      define GLOBAL_ERROR_HANDLING PG(error_handling)
 #      define GLOBAL_EXCEPTION_CLASS PG(exception_class)
-#      define IS_CALLABLE(cb_zv, flags, cb_sp) zend_is_callable((cb_zv), (flags), (cb_sp))
+#      define HTTP_IS_CALLABLE(cb_zv, flags, cb_sp) zend_is_callable((cb_zv), (flags), (cb_sp))
 #      define HTTP_STATIC_ARG_INFO static
 #endif
 
index 4266aa66d8040db2b9268f0f5789fe8ba6c996d8..cdbfe09673e17be7e7c92e1a844e4cfd5202d2ac 100644 (file)
@@ -28,9 +28,9 @@ support. Parallel requests are available for PHP 5 and greater.
   <email>mike@php.net</email>
   <active>yes</active>
  </lead>
- <date>2010-06-09</date>
+ <date>2013-06-20</date>
  <version>
-  <release>1.7.0</release>
+  <release>1.7.6</release>
   <api>1.7.0</api>
  </version>
  <stability>
@@ -39,23 +39,7 @@ support. Parallel requests are available for PHP 5 and greater.
  </stability>
  <license>BSD, revised</license>
  <notes><![CDATA[
-* Added generic http_negotiate() function (FR#17338)
-* Added request options:
- - proxytunnel: enable tunelling through the HTTP proxy
- - noproxy: comma separatet list of hosts (* means all hosts) not to use a proxy for (libcurl >= 7.19.4)
-* Added postredir request options constants:
- - HTTP_POSTREDIR_301
- - HTTP_POSTREDIR_302
- - HTTP_POSTREDIR_ALL
-* Added authtype request option constant:
- - HTTP_AUTH_DIGEST_IE
-* Added proxytype request option constants:
- - HTTP_PROXY_HTTP_1_0
-* Added request info members:
- - condition_unmet (libcurl >= 7.19.4)
-* Fixed bug #16893 (Content not decoded with zlib support and compress enabled)
-* Fixed bug #17087 (http_build_cookie() exhausts memory if cookie value is NULL)
-* Fixed bug #17169 (Wrong return value of HttpMessage::getHttpVersion())
+* Fixed bug #64380 (PHP-5.5 build fails)
 ]]></notes>
  <contents>
   <dir name="/">
@@ -276,8 +260,6 @@ support. Parallel requests are available for PHP 5 and greater.
   <required>
    <php>
     <min>4.3</min>
-    <max>6.0.0</max>
-    <exclude>6.0.0</exclude>
    </php>
    <pearinstaller>
     <min>1.4.1</min>
index 630ef8258575fde0007668fdc9a3ce9bb409e797..e4a0f85d8fd7cfe82cd81b4a6cd186d88fa8e51c 100644 (file)
@@ -15,7 +15,7 @@
 #ifndef PHP_EXT_HTTP_H
 #define PHP_EXT_HTTP_H
 
-#define PHP_HTTP_VERSION "1.7.0"
+#define PHP_HTTP_VERSION "1.7.6"
 
 #ifdef HAVE_CONFIG_H
 #      include "config.h"
index fdee36d80bfcec98c42fa38e7b4da2c7e76fb147..3a64350eca71abc1458be02aaf14b433839a5199 100644 (file)
@@ -96,12 +96,18 @@ extern STATUS _http_object_new(zend_object_value *ov, const char *cname_str, uin
                http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, "Invalid compression level (-1 to 9): %d", level); \
                action; \
        }
-
+#ifndef PHP_OUTPUT_NEWAPI
+#      define HTTP_GET_OUTPUT_START() \
+               char *output_start_filename = php_get_output_start_filename(TSRMLS_C); \
+               int output_start_lineno = php_get_output_start_lineno(TSRMLS_C)
+#else
+#      define HTTP_GET_OUTPUT_START() \
+               char *output_start_filename = php_output_get_start_filename(TSRMLS_C); \
+               int output_start_lineno = php_output_get_start_lineno(TSRMLS_C)
+#endif
 #define HTTP_CHECK_HEADERS_SENT(action) \
        if (SG(headers_sent) && !SG(request_info).no_headers) { \
-               char *output_start_filename = php_get_output_start_filename(TSRMLS_C); \
-               int output_start_lineno = php_get_output_start_lineno(TSRMLS_C); \
-                \
+               HTTP_GET_OUTPUT_START(); \
                if (output_start_filename) { \
                        http_error_ex(HE_WARNING, HTTP_E_HEADER, "Cannot modify header information - headers already sent by (output started at %s:%d)", \
                                output_start_filename, output_start_lineno); \
@@ -251,7 +257,7 @@ static inline zval *_http_zset(int type, zval *z)
 #define http_zsep(t, z) _http_zsep_ex((t), (z), NULL)
 #define http_zsep_ex(t, z, p) _http_zsep_ex((t), (z), (p))
 static inline zval *_http_zsep_ex(int type, zval *z, zval **p) {
-       SEPARATE_ARG_IF_REF(z);
+       ZVAL_ADDREF(z);
        if (Z_TYPE_P(z) != type) {
                switch (type) {
                        case IS_NULL:   convert_to_null_ex(&z);         break;
@@ -262,6 +268,8 @@ static inline zval *_http_zsep_ex(int type, zval *z, zval **p) {
                        case IS_ARRAY:  convert_to_array_ex(&z);        break;
                        case IS_OBJECT: convert_to_object_ex(&z);       break;
                }
+       } else {
+               SEPARATE_ZVAL_IF_NOT_REF(&z);
        }
        if (p) {
                *p = z;
index 456ae74ca4a8f2a04d0af87bc53d926adfca7050..32c12333ae0062cdfad3867867735f051c647daf 100644 (file)
@@ -182,7 +182,11 @@ typedef int STATUS;
 #      define getObject(t, o) getObjectEx(t, o, getThis())
 #      define getObjectEx(t, o, v) t * o = ((t *) zend_object_store_get_object(v TSRMLS_CC))
 #      define putObject(t, o) zend_objects_store_put(o, (zend_objects_store_dtor_t) zend_objects_destroy_object, (zend_objects_free_object_storage_t) _ ##t## _free, NULL TSRMLS_CC);
-#      ifndef WONKY
+#      if defined(ZEND_ENGINE_2_4)
+#              define freeObject(o) \
+                       zend_object_std_dtor(o TSRMLS_CC); \
+                       efree(o);
+#      elif !defined(WONKY)
 #              define freeObject(o) \
                        if (OBJ_GUARDS(o)) { \
                                zend_hash_destroy(OBJ_GUARDS(o)); \
@@ -329,6 +333,13 @@ typedef int STATUS;
                                ZEND_ARG_PASS_INFO(0) \
                                ZEND_ARG_PASS_INFO(1) \
                        ZEND_END_ARG_INFO(); \
+\
+                       HTTP_STATIC_ARG_INFO \
+                       ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_3, 0) \
+                               ZEND_ARG_PASS_INFO(0) \
+                               ZEND_ARG_PASS_INFO(0) \
+                               ZEND_ARG_PASS_INFO(1) \
+                       ZEND_END_ARG_INFO(); \
 \
                        HTTP_STATIC_ARG_INFO \
                        ZEND_BEGIN_ARG_INFO(http_arg_pass_ref_4, 0) \
@@ -340,6 +351,7 @@ typedef int STATUS;
 #      else
 #              define HTTP_DECLARE_ARG_PASS_INFO() \
                        static unsigned char http_arg_pass_ref_2[] = {2, BYREF_NONE, BYREF_FORCE}; \
+                       static unsigned char http_arg_pass_ref_3[] = {3, BYREF_NONE, BYREF_NONE, BYREF_FORCE}; \
                        static unsigned char http_arg_pass_ref_4[] = {4, BYREF_NONE, BYREF_NONE, BYREF_NONE, BYREF_FORCE};
 #      endif /* ZEND_ENGINE_2 */
 #endif /* HTTP_HAVE_CURL */
index f234685ea7abc8c36b4a936427e9325315b3a031..b69c96c5e2a781513fd4073e5aefb5de355ac5e7 100644 (file)
@@ -36,11 +36,16 @@ $ifdefs = array(
        'PRIMARY_IP' => 'HTTP_CURL_VERSION(7,19,0)',
        'APPCONNECT_TIME' => 'HTTP_CURL_VERSION(7,19,0)',
        'REDIRECT_URL' => 'HTTP_CURL_VERSION(7,18,2)',
-       'CONDITION_UNMET' => 'HTTP_CURL_VERSION(7,19,4)',
+    'CONDITION_UNMET' => 'HTTP_CURL_VERSION(7,19,4)',
+    'PRIMARY_PORT' => 'HTTP_CURL_VERSION(7,21,0)',
+    'LOCAL_PORT' => 'HTTP_CURL_VERSION(7,21,0)',
+    'LOCAL_IP' => 'HTTP_CURL_VERSION(7,21,0)',
 );
 $exclude = array(
-       'PRIVATE', 'LASTSOCKET', 'FTP_ENTRY_PATH', 'CERTINFO',
+    'PRIVATE', 'LASTSOCKET', 'FTP_ENTRY_PATH', 'CERTINFO',
+    'RTSP_SESSION_ID', 'RTSP_CLIENT_CSEQ', 'RTSP_SERVER_CSEQ', 'RTSP_CSEQ_RECV'
 );
+
 $translate = array(
        'HTTP_CONNECTCODE' => "connect_code",
        'COOKIELIST' => 'cookies',
index 067e36c477d702c95645e76e959b43130f8b8d78..8989de1b8699fda8d4aba79d4d894d24d908b896 100644 (file)
@@ -43,10 +43,10 @@ HTTP/1.1 100 Continue
 HTTP/1.1 200 OK
 Date: %a
 Server: %a
-X-Powered-By: %a
 Vary: Accept-Encoding
-Content-Length: %d
 Content-Type: text/html
+X-Original-Transfer-Encoding: chunked
+Content-Length: %d
 
 <?php
 echo "-TEST\n";
index 8282c84900359bce9e26d8ab53d48e70aec3c572..fad5b400cc22f44923f2cea822301484807fa52f 100644 (file)
@@ -36,7 +36,7 @@ array(1) refcount(2){
   ["ssl"]=>
   array(1) refcount(1){
     ["verifypeer"]=>
-    string(1) "1" refcount(2)
+    string(1) "1" refcount(3)
   }
 }
 array(1) refcount(2){
index 81f9bc4e66a2f24cbc24f92b71eddb8fa5830eff..3c5ae6f913c924f81d390a8765201d5e3bc7f3b0 100644 (file)
@@ -25,14 +25,16 @@ object(stdClass)%a {
   ["responseStatus"]=>
   string(2) "OK"
   ["headers"]=>
-  array(8) {
+  array(%d) {
     %a
     ["Vary"]=>
     string(15) "Accept-Encoding"
-    ["Content-Length"]=>
-    string(2) "26"
     ["Content-Type"]=>
     string(9) "text/html"
+    ["X-Original-Transfer-Encoding"]=>
+    string(7) "chunked"
+    ["Content-Length"]=>
+    string(2) "26"
     ["X-Original-Content-Encoding"]=>
     string(4) "gzip"
     ["X-Original-Content-Length"]=>