Merge branch 'R_2_0'
authorMichael Wallner <mike@php.net>
Tue, 22 Apr 2014 10:18:44 +0000 (12:18 +0200)
committerMichael Wallner <mike@php.net>
Tue, 22 Apr 2014 10:18:44 +0000 (12:18 +0200)
php_http_env.c
php_http_message.c
php_http_misc.c

index fdc7b9696a0f80e6736436660e849af70b48a50f..30ee32d7c68b3341aeaeb24c909b102537caccdf 100644 (file)
@@ -957,8 +957,11 @@ static SAPI_POST_HANDLER_FUNC(php_http_json_post_handler)
        size_t json_len = 0;
 
 #if PHP_VERSION_ID >= 50600
-       php_http_message_body_to_string(php_http_env_get_request_body(TSRMLS_C),
-                       &json_str, &json_len, 0, -1);
+       if (SG(request_info).request_body) {
+               /* FG(stream_wrappers) not initialized yet, so we cannot use php://input */
+               php_stream_rewind(SG(request_info).request_body);
+               json_len = php_stream_copy_to_mem(SG(request_info).request_body, &json_str, PHP_STREAM_COPY_ALL, 0);
+       }
 #else
        json_str = SG(request_info).raw_post_data;
        json_len = SG(request_info).raw_post_data_length;
index a6414e400dea8182bf3324c828d4d572e26e7d9b..0ffdd9e5002572110231e9fd768554a332934af1 100644 (file)
@@ -784,7 +784,7 @@ STATUS php_http_message_object_set_body(php_http_message_object_t *msg_obj, zval
 
 STATUS php_http_message_object_init_body_object(php_http_message_object_t *obj)
 {
-       TSRMLS_FETCH_FROM_CTX(obj);
+       TSRMLS_FETCH_FROM_CTX(obj->message->ts);
 
        php_http_message_body_addref(obj->message->body);
        return php_http_new(NULL, php_http_message_body_class_entry, (php_http_new_t) php_http_message_body_object_new_ex, NULL, obj->message->body, (void *) &obj->body TSRMLS_CC);
index 0515c961b597629b388c4df68cc5090d64ad48ad..03b9560483c92198c74de9baec824262c3c05048 100644 (file)
@@ -61,7 +61,8 @@ int php_http_match(const char *haystack_str, const char *needle_str, int flags)
                        result = !strcasecmp(haystack_str, needle_str);
                }
        } else {
-               char *found, *haystack = estrdup(haystack_str), *needle = estrdup(needle_str);
+               const char *found;
+               char *haystack = estrdup(haystack_str), *needle = estrdup(needle_str);
 
                if (flags & PHP_HTTP_MATCH_CASE) {
                        found = zend_memnstr(haystack, needle, strlen(needle), haystack+strlen(haystack));