fix bug with request_pool+libevent+add-requests-while-running
[m6w6/ext-http] / http_api.c
index 77b11348c0a0bfc484d3120de9dcb2b1a08ab12b..04247fa310d771ac16a9fc99e810671ff1f7db56 100644 (file)
@@ -357,6 +357,9 @@ PHP_HTTP_API STATUS _http_get_request_body_ex(char **body, size_t *length, zend_
                        memcpy(*body + *length, buf, len);
                        *length += len;
                        (*body)[*length] = '\0';
+                       if (len < (int) sizeof(buf)) {
+                               break;
+                       }
                }
                
                /* check for error */
@@ -395,6 +398,9 @@ PHP_HTTP_API php_stream *_http_get_request_body_stream(TSRMLS_D)
                        
                        while (0 < (len = sapi_module.read_post(buf, sizeof(buf) TSRMLS_CC))) {
                                php_stream_write(s, buf, len);
+                               if (len < (int) sizeof(buf)) {
+                                       break;
+                               }
                        }
                        
                        if (len < 0) {
@@ -549,15 +555,6 @@ PHP_HTTP_API STATUS _http_parse_params_ex(const char *param, int flags, http_par
                                                goto failure;
                                                break;
                                        
-                                       case '=':
-                                               if (key) {
-                                                       keylen = c - key;
-                                                       st = ST_VALUE;
-                                               } else {
-                                                       goto failure;
-                                               }
-                                               break;
-                                       
                                        case ' ':
                                                if (key) {
                                                        keylen = c - key;
@@ -574,7 +571,32 @@ PHP_HTTP_API STATUS _http_parse_params_ex(const char *param, int flags, http_par
                                                }
                                                break;
                                        
+                                       case ':':
+                                               if (!(flags & HTTP_PARAMS_COLON_SEPARATOR)) {
+                                                       goto not_separator;
+                                               }
+                                               if (key) {
+                                                       keylen = c - key;
+                                                       st = ST_VALUE;
+                                               } else {
+                                                       goto failure;
+                                               }
+                                               break;
+                                               
+                                       case '=':
+                                               if (flags & HTTP_PARAMS_COLON_SEPARATOR) {
+                                                       goto not_separator;
+                                               }
+                                               if (key) {
+                                                       keylen = c - key;
+                                                       st = ST_VALUE;
+                                               } else {
+                                                       goto failure;
+                                               }
+                                               break;
+                                       
                                        default:
+                                       not_separator:
                                                if (!key) {
                                                        key = c;
                                                }
@@ -646,7 +668,7 @@ failure:
 /* }}} */
 
 /* {{{ array_join */
-int apply_array_append_func(void *pDest, int num_args, va_list args, zend_hash_key *hash_key)
+int apply_array_append_func(void *pDest HTTP_ZAPI_HASH_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
 {
        int flags;
        char *key = NULL;
@@ -666,10 +688,7 @@ int apply_array_append_func(void *pDest, int num_args, va_list args, zend_hash_k
                
                ZVAL_ADDREF(*value);
                if (data) {
-                       if (Z_TYPE_PP(data) != IS_ARRAY) {
-                               convert_to_array(*data);
-                       }
-                       add_next_index_zval(*data, *value);
+                       add_next_index_zval(http_zset(IS_ARRAY, *data), *value);
                } else if (key) {
                        zend_hash_add(dst, key, hash_key->nKeyLength, value, sizeof(zval *), NULL);
                } else {
@@ -684,7 +703,7 @@ int apply_array_append_func(void *pDest, int num_args, va_list args, zend_hash_k
        return ZEND_HASH_APPLY_KEEP;
 }
 
-int apply_array_merge_func(void *pDest, int num_args, va_list args, zend_hash_key *hash_key)
+int apply_array_merge_func(void *pDest HTTP_ZAPI_HASH_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
 {
        int flags;
        char *key = NULL;