fix bug with request_pool+libevent+add-requests-while-running
[m6w6/ext-http] / http_api.c
index b54da54d2f0149395760dfa5746bcb2f989c9cff..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;
                                                }
@@ -666,10 +688,7 @@ int apply_array_append_func(void *pDest HTTP_ZAPI_HASH_TSRMLS_DC, int num_args,
                
                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 {