Merge branch 'v2.5.x'
authorMichael Wallner <mike@php.net>
Tue, 19 Jan 2016 09:40:09 +0000 (10:40 +0100)
committerMichael Wallner <mike@php.net>
Tue, 19 Jan 2016 09:40:09 +0000 (10:40 +0100)
1  2 
README.md
scripts/gen_travis_yml.php
src/php_http_message.c

diff --cc README.md
+++ b/README.md
@@@ -1,7 -1,7 +1,8 @@@
  # ext-http
  
 -[![Build Status](https://travis-ci.org/m6w6/ext-http.svg?branch=v2.5.x)](https://travis-ci.org/m6w6/ext-http)
 +[![Build Status](https://travis-ci.org/m6w6/ext-http.svg?branch=master)](https://travis-ci.org/m6w6/ext-http)
- [![Join the chat at https://gitter.im/m6w6/ext-http](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/m6w6/ext-http?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+ [![Join the chat at https://gitter.im/m6w6/ext-http](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/m6w6/ext-http)
++>>>>>>> v2.5.x
  
  Extended HTTP support. Again.
  
@@@ -34,10 -32,11 +34,11 @@@ foreach ($env as $e) 
  
  before_script:
   - make -f travis/pecl/Makefile php
-  - make -f travis/pecl/Makefile pharext/raphf-master pharext/propro-master
 - - make -f travis/pecl/Makefile pecl PECL=raphf:raphf:1.1.1
 - - make -f travis/pecl/Makefile pecl PECL=propro:propro:1.0.2
++ - make -f travis/pecl/Makefile pecl PECL=raphf:raphf:2.0.0
++ - make -f travis/pecl/Makefile pecl PECL=propro:propro:2.0.0
+  - make -f travis/pecl/Makefile ext PECL=http
  
  script:
-  - make -f travis/pecl/Makefile ext PECL=http
   - make -f travis/pecl/Makefile test
  
  after_script:
@@@ -58,19 -59,20 +58,20 @@@ php_http_message_t *php_http_message_in
  
        switch (type) {
                case PHP_HTTP_REQUEST:
 -                      mbody = php_http_env_get_request_body(TSRMLS_C);
 +                      mbody = php_http_env_get_request_body();
                        php_http_message_body_addref(mbody);
 -                      message = php_http_message_init(message, type, mbody TSRMLS_CC);
 -                      if ((sval = php_http_env_get_server_var(ZEND_STRL("SERVER_PROTOCOL"), 1 TSRMLS_CC)) && !strncmp(Z_STRVAL_P(sval), "HTTP/", lenof("HTTP/"))) {
 -                              php_http_version_parse(&message->http.version, Z_STRVAL_P(sval) TSRMLS_CC);
 +                      message = php_http_message_init(message, type, mbody);
 +                      if ((sval = php_http_env_get_server_var(ZEND_STRL("SERVER_PROTOCOL"), 1)) && !strncmp(Z_STRVAL_P(sval), "HTTP/", lenof("HTTP/"))) {
 +                              php_http_version_parse(&message->http.version, Z_STRVAL_P(sval));
                        }
 -                      if ((sval = php_http_env_get_server_var(ZEND_STRL("REQUEST_METHOD"), 1 TSRMLS_CC))) {
 +                      if ((sval = php_http_env_get_server_var(ZEND_STRL("REQUEST_METHOD"), 1))) {
                                message->http.info.request.method = estrdup(Z_STRVAL_P(sval));
                        }
 -                      if ((sval = php_http_env_get_server_var(ZEND_STRL("REQUEST_URI"), 1 TSRMLS_CC))) {
 -                              message->http.info.request.url = php_http_url_parse(Z_STRVAL_P(sval), Z_STRLEN_P(sval), ~0 TSRMLS_CC);
 +                      if ((sval = php_http_env_get_server_var(ZEND_STRL("REQUEST_URI"), 1))) {
 +                              message->http.info.request.url = php_http_url_parse(Z_STRVAL_P(sval), Z_STRLEN_P(sval), ~0);
                        }
 -                      php_http_env_get_request_headers(&message->hdrs TSRMLS_CC);
 +                      php_http_env_get_request_headers(&message->hdrs);
                        break;
  
                case PHP_HTTP_RESPONSE:
                                }
                                message->http.info.response.status = estrdup(php_http_env_get_response_status_for_code(message->http.info.response.code));
                        }
-                       
 -                      php_http_env_get_response_headers(&message->hdrs TSRMLS_CC);
 -#if PHP_VERSION_ID >= 50400
 -                      if (php_output_get_level(TSRMLS_C)) {
 -                              if (php_output_get_status(TSRMLS_C) & PHP_OUTPUT_SENT) {
 -                                      php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not fetch response body, output has already been sent at %s:%d", php_output_get_start_filename(TSRMLS_C), php_output_get_start_lineno(TSRMLS_C));
 -                                      goto error;
 -                              } else if (SUCCESS != php_output_get_contents(&tval TSRMLS_CC)) {
 -                                      php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not fetch response body");
 -                                      goto error;
 -                              } else {
 -                                      php_http_message_body_append(message->body, Z_STRVAL(tval), Z_STRLEN(tval));
 -                                      zval_dtor(&tval);
 -                              }
 -                      }
 -#else
 -                      if (OG(ob_nesting_level)) {
 -                              if (php_get_output_start_filename(TSRMLS_C)) {
 -                                      php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not fetch response body, output has already been sent at %s:%d", php_get_output_start_filename(TSRMLS_C), php_get_output_start_lineno(TSRMLS_C));
 +                      php_http_env_get_response_headers(&message->hdrs);
 +                      if (php_output_get_level()) {
 +                              if (php_output_get_status() & PHP_OUTPUT_SENT) {
 +                                      php_error_docref(NULL, E_WARNING, "Could not fetch response body, output has already been sent at %s:%d", php_output_get_start_filename(), php_output_get_start_lineno());
++
                                        goto error;
 -                              } else if (SUCCESS != php_ob_get_buffer(&tval TSRMLS_CC)) {
 -                                      php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not fetch response body");
 +                              } else if (SUCCESS != php_output_get_contents(&tval)) {
 +                                      php_error_docref(NULL, E_WARNING, "Could not fetch response body");
                                        goto error;
                                } else {
                                        php_http_message_body_append(message->body, Z_STRVAL(tval), Z_STRLEN(tval));
@@@ -408,8 -439,10 +410,8 @@@ void php_http_message_serialize(php_htt
  
  php_http_message_t *php_http_message_reverse(php_http_message_t *msg)
  {
 -      int i, c = 0;
 -
 -      php_http_message_count(c, msg);
 +      size_t i, c = php_http_message_count(msg);
-       
        if (c > 1) {
                php_http_message_t *tmp = msg, **arr;
  
@@@ -452,23 -485,23 +454,22 @@@ php_http_message_t *php_http_message_co
  {
        php_http_message_t *temp, *copy = NULL;
        php_http_info_t info;
-       
 -      TSRMLS_FETCH_FROM_CTX(from->ts);
        if (from) {
                info.type = from->type;
                info.http = from->http;
-               
 -              copy = temp = php_http_message_init(to, 0, php_http_message_body_copy(from->body, NULL) TSRMLS_CC);
 +              copy = temp = php_http_message_init(to, 0, php_http_message_body_copy(from->body, NULL));
                php_http_message_set_info(temp, &info);
 -              zend_hash_copy(&temp->hdrs, &from->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
 +              zend_hash_copy(&temp->hdrs, &from->hdrs, (copy_ctor_func_t) zval_add_ref);
-       
                if (parents) while (from->parent) {
                        info.type = from->parent->type;
                        info.http = from->parent->http;
-               
 -                      temp->parent = php_http_message_init(NULL, 0, php_http_message_body_copy(from->parent->body, NULL) TSRMLS_CC);
 +                      temp->parent = php_http_message_init(NULL, 0, php_http_message_body_copy(from->parent->body, NULL));
                        php_http_message_set_info(temp->parent, &info);
 -                      zend_hash_copy(&temp->parent->hdrs, &from->parent->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
 +                      array_copy(&from->parent->hdrs, &temp->parent->hdrs);
-               
  
                        temp = temp->parent;
                        from = from->parent;
@@@ -943,14 -972,23 +944,14 @@@ static HashTable *php_http_message_obje
        size_t ver_len, url_len = 0;
  
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 -      INIT_PZVAL_ARRAY(&array, props);
 +      *is_temp = 0;
-       
 -#define ASSOC_PROP(ptype, n, val) \
 +#define UPDATE_PROP(name_str, action_with_tmp) \
        do { \
                zend_property_info *pi; \
 -              if (SUCCESS == zend_hash_find(&obj->zo.ce->properties_info, n, sizeof(n), (void *) &pi)) { \
 -                      add_assoc_ ##ptype## _ex(&array, pi->name, pi->name_length + 1, val); \
 -              } \
 -      } while(0) \
 -
 -#define ASSOC_STRING(name, val) ASSOC_STRINGL(name, val, strlen(val))
 -#define ASSOC_STRINGL(name, val, len) ASSOC_STRINGL_EX(name, val, len, 1)
 -#define ASSOC_STRINGL_EX(n, val, len, cpy) \
 -      do { \
 -              zend_property_info *pi; \
 -              if (SUCCESS == zend_hash_find(&obj->zo.ce->properties_info, n, sizeof(n), (void *) &pi)) { \
 -                      add_assoc_stringl_ex(&array, pi->name, pi->name_length + 1, val, len, cpy); \
 +              if ((pi = zend_hash_str_find_ptr(&obj->zo.ce->properties_info, name_str, lenof(name_str)))) { \
 +                      action_with_tmp; \
 +                      zend_hash_update_ind(props, pi->name, &tmp); \
                } \
        } while(0)