flush WIP
authorMichael Wallner <mike@php.net>
Wed, 14 Jan 2015 20:53:09 +0000 (21:53 +0100)
committerMichael Wallner <mike@php.net>
Wed, 14 Jan 2015 20:53:09 +0000 (21:53 +0100)
50 files changed:
package.xml
php_http.c
php_http.h
php_http_api.h
php_http_buffer.c
php_http_buffer.h
php_http_client.c
php_http_client.h
php_http_client_curl.c
php_http_cookie.c
php_http_cookie.h
php_http_encoding.c
php_http_encoding.h
php_http_env.c
php_http_env.h
php_http_env_response.c
php_http_env_response.h
php_http_etag.c
php_http_etag.h
php_http_exception.c
php_http_exception.h
php_http_filter.c
php_http_header.c
php_http_header.h
php_http_header_parser.c
php_http_header_parser.h
php_http_info.c
php_http_info.h
php_http_message.c
php_http_message.h
php_http_message_body.c
php_http_message_body.h
php_http_message_parser.c
php_http_message_parser.h
php_http_misc.c
php_http_misc.h
php_http_negotiate.c
php_http_negotiate.h
php_http_object.c
php_http_object.h
php_http_options.c
php_http_options.h
php_http_params.h
php_http_querystring.c
php_http_querystring.h
php_http_strlist.c
php_http_url.c
php_http_url.h
php_http_version.c
php_http_version.h

index 56bce0c..726d2c2 100644 (file)
@@ -22,13 +22,7 @@ arbitrary data with caching and resuming capabilities.
 It provides powerful request functionality with support for
 parallel requests.
 
-Documentation:
-v1: http://php.net/http
-v2: http://devel-m6w6.rhcloud.com/mdref/http
-
-Code Coverage:
-v1: http://dev.iworks.at/ext-http/lcov_html/ext/http/
-v2: http://dev.iworks.at/ext-http/lcov/ext/http/
+http://devel-m6w6.rhcloud.com/mdref/http
 
 ]]></description>
  <lead>
@@ -37,10 +31,10 @@ v2: http://dev.iworks.at/ext-http/lcov/ext/http/
   <email>mike@php.net</email>
   <active>yes</active>
  </lead>
- <date>2014-11-12</date>
+ <date>2014-12-17</date>
  <version>
-  <release>2.2.0dev</release>
-  <api>2.2.0</api>
+  <release>3.0.0dev</release>
+  <api>3.0.0</api>
  </version>
  <stability>
   <release>beta</release>
@@ -48,12 +42,7 @@ v2: http://dev.iworks.at/ext-http/lcov/ext/http/
  </stability>
  <license>BSD, revised</license>
  <notes><![CDATA[
-- var_dump(http\Message) no longer automatically creates an empty body
-+ Added http\Message\Parser class
-+ Made http\Client::once() and http\Client::wait() available when using events
-+ Added http\Url::PARSE_MBLOC, http\Url::PARSE_MBUTF8, http\Url::PARSE_TOIDN and http\Url::PARSE_TOPCT constants
-+ Added http\Env\Response::setCookie()
-+ Added http\Env\Request::getCookie()
+*
 ]]></notes>
  <contents>
   <dir name="/">
index f7a0b86..0bf09ac 100644 (file)
@@ -117,14 +117,6 @@ static inline void php_http_globals_free(zend_php_http_globals *G TSRMLS_DC)
 }
 #endif
 
-#if ZTS && PHP_DEBUG && !HAVE_GCOV
-zend_php_http_globals *php_http_globals(void)
-{
-       TSRMLS_FETCH();
-       return PHP_HTTP_G;
-}
-#endif
-
 PHP_INI_BEGIN()
        STD_PHP_INI_ENTRY("http.etag.mode", "crc32b", PHP_INI_ALL, OnUpdateString, env.etag_mode, zend_php_http_globals, php_http_globals)
 PHP_INI_END()
index 98332cb..13afc0f 100644 (file)
@@ -13,7 +13,7 @@
 #ifndef PHP_EXT_HTTP_H
 #define PHP_EXT_HTTP_H
 
-#define PHP_PECL_HTTP_VERSION "2.2.0dev"
+#define PHP_PECL_HTTP_VERSION "3.0.0dev"
 
 extern zend_module_entry http_module_entry;
 #define phpext_http_ptr &http_module_entry
index 5bddb0c..1a848b2 100644 (file)
@@ -41,9 +41,6 @@
 # define PHP_HTTP_API extern
 #endif
 
-/* make functions that return SUCCESS|FAILURE more obvious */
-typedef int STATUS;
-
 #if (defined(HAVE_ICONV) || defined(PHP_HTTP_HAVE_EXT_ICONV)) && (PHP_HTTP_SHARED_DEPS || !defined(COMPILE_DL_ICONV))
 #      define PHP_HTTP_HAVE_ICONV
 #endif
@@ -118,9 +115,9 @@ ZEND_EXTERN_MODULE_GLOBALS(php_http);
 
 #ifdef ZTS
 #      include "TSRM/TSRM.h"
-#      define PHP_HTTP_G ((zend_php_http_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(php_http_globals_id)])
+#      define PHP_HTTP_G ((zend_php_http_globals *) (*((void ***) tsrm_get_ls_cache()))[TSRM_UNSHUFFLE_RSRC_ID(php_http_globals_id)])
 #      undef TSRMLS_FETCH_FROM_CTX
-#      define TSRMLS_FETCH_FROM_CTX(ctx) void ***tsrm_ls = ((ctx)?(ctx):ts_resource_ex(0, NULL))
+#      define TSRMLS_FETCH_FROM_CTX(ctx) ERROR
 #else
 #      define PHP_HTTP_G (&php_http_globals)
 #endif
index 6636e2c..059db06 100644 (file)
@@ -13,7 +13,8 @@
 #include <php.h>
 #include "php_http_buffer.h"
 
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_init_ex(php_http_buffer_t *buf, size_t chunk_size, int flags)
+PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_init_ex(
+               php_http_buffer_t *buf, size_t chunk_size, unsigned flags)
 {
        if (!buf) {
                buf = pemalloc(sizeof(*buf), flags & PHP_HTTP_BUFFER_INIT_PERSISTENT);
@@ -22,7 +23,8 @@ PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_init_ex(php_http_buffer_t
        if (buf) {
                buf->size = (chunk_size) ? chunk_size : PHP_HTTP_BUFFER_DEFAULT_SIZE;
                buf->pmem = (flags & PHP_HTTP_BUFFER_INIT_PERSISTENT) ? 1 : 0;
-               buf->data = (flags & PHP_HTTP_BUFFER_INIT_PREALLOC) ? pemalloc(buf->size, buf->pmem) : NULL;
+               buf->data = (flags & PHP_HTTP_BUFFER_INIT_PREALLOC) ?
+                               pemalloc(buf->size, buf->pmem) : NULL;
                buf->free = (flags & PHP_HTTP_BUFFER_INIT_PREALLOC) ? buf->size : 0;
                buf->used = 0;
        }
@@ -30,10 +32,11 @@ PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_init_ex(php_http_buffer_t
        return buf;
 }
 
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_from_string_ex(php_http_buffer_t *buf, const char *string, size_t length)
+PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_from_string_ex(
+               php_http_buffer_t *buf, const char *str, size_t len)
 {
        if ((buf = php_http_buffer_init(buf))) {
-               if (PHP_HTTP_BUFFER_NOMEM == php_http_buffer_append(buf, string, length)) {
+               if (PHP_HTTP_BUFFER_NOMEM == php_http_buffer_append(buf, str, len)) {
                        pefree(buf, buf->pmem);
                        buf = NULL;
                }
@@ -41,7 +44,9 @@ PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_from_string_ex(php_http_b
        return buf;
 }
 
-PHP_HTTP_BUFFER_API size_t php_http_buffer_resize_ex(php_http_buffer_t *buf, size_t len, size_t override_size, int allow_error)
+PHP_HTTP_BUFFER_API size_t php_http_buffer_resize_ex(
+               php_http_buffer_t *buf, size_t len, size_t override_size,
+               zend_bool allow_error)
 {
        char *ptr = NULL;
 #if 0
@@ -55,7 +60,8 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_resize_ex(php_http_buffer_t *buf, siz
                }
                
                if (allow_error) {
-                       ptr = perealloc_recoverable(buf->data, buf->used + buf->free + size, buf->pmem);
+                       ptr = perealloc_recoverable(buf->data,
+                                       buf->used + buf->free + size, buf->pmem);
                } else {
                        ptr = perealloc(buf->data, buf->used + buf->free + size, buf->pmem);
                }
@@ -72,7 +78,8 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_resize_ex(php_http_buffer_t *buf, siz
        return 0;
 }
 
-PHP_HTTP_BUFFER_API char *php_http_buffer_account(php_http_buffer_t *buf, size_t to_account)
+PHP_HTTP_BUFFER_API char *php_http_buffer_account(
+               php_http_buffer_t *buf, size_t to_account)
 {
        /* it's probably already too late but check anyway */
        if (to_account > buf->free) {
@@ -101,9 +108,12 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_shrink(php_http_buffer_t *buf)
        return buf->used;
 }
 
-PHP_HTTP_BUFFER_API size_t php_http_buffer_append(php_http_buffer_t *buf, const char *append, size_t append_len)
+PHP_HTTP_BUFFER_API size_t php_http_buffer_append(php_http_buffer_t *buf,
+               const char *append, size_t append_len)
 {
-       if (buf->free < append_len && PHP_HTTP_BUFFER_NOMEM == php_http_buffer_resize(buf, append_len)) {
+       if (    buf->free < append_len &&
+                       PHP_HTTP_BUFFER_NOMEM == php_http_buffer_resize(buf, append_len)
+       ) {
                return PHP_HTTP_BUFFER_NOMEM;
        }
        memcpy(buf->data + buf->used, append, append_len);
@@ -112,7 +122,8 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_append(php_http_buffer_t *buf, const
        return append_len;
 }
 
-PHP_HTTP_BUFFER_API size_t php_http_buffer_appendf(php_http_buffer_t *buf, const char *format, ...)
+PHP_HTTP_BUFFER_API size_t php_http_buffer_appendf(php_http_buffer_t *buf,
+               const char *format, ...)
 {
        va_list argv;
        char *append;
@@ -131,7 +142,8 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_appendf(php_http_buffer_t *buf, const
        return append_len;
 }
 
-PHP_HTTP_BUFFER_API char *php_http_buffer_data(const php_http_buffer_t *buf, char **into, size_t *len)
+PHP_HTTP_BUFFER_API char *php_http_buffer_data(const php_http_buffer_t *buf,
+               char **into, size_t *len)
 {
        char *copy = ecalloc(1, buf->used + 1);
        memcpy(copy, buf->data, buf->used);
@@ -144,7 +156,8 @@ PHP_HTTP_BUFFER_API char *php_http_buffer_data(const php_http_buffer_t *buf, cha
        return copy;
 }
 
-PHP_HTTP_BUFFER_API size_t php_http_buffer_cut(php_http_buffer_t *buf, size_t offset, size_t length)
+PHP_HTTP_BUFFER_API size_t php_http_buffer_cut(php_http_buffer_t *buf,
+               size_t offset, size_t length)
 {
        if (offset > buf->used) {
                return 0;
@@ -152,15 +165,19 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_cut(php_http_buffer_t *buf, size_t of
        if (offset + length > buf->used) {
                length = buf->used - offset;
        }
-       memmove(buf->data + offset, buf->data + offset + length, buf->used - length - offset);
+       memmove(buf->data + offset, buf->data + offset + length,
+                       buf->used - length - offset);
        buf->used -= length;
        buf->free += length;
        return length;
 }
 
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_fix(php_http_buffer_t *buf)
+PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_fix(
+               php_http_buffer_t *buf)
 {
-       if (buf->free < 1 && PHP_HTTP_BUFFER_NOMEM == php_http_buffer_resize_ex(buf, 1, 1, 0)) {
+       if (    buf->free < 1 &&
+                       PHP_HTTP_BUFFER_NOMEM == php_http_buffer_resize_ex(buf, 1, 1, 0)
+       ) {
                return NULL;
        }
        buf->data[buf->used] = '\0';
@@ -192,14 +209,16 @@ PHP_HTTP_BUFFER_API void php_http_buffer_free(php_http_buffer_t **buf)
        }
 }
 
-PHP_HTTP_BUFFER_API size_t php_http_buffer_chunk_buffer(php_http_buffer_t **s, const char *data, size_t data_len, char **chunk, size_t chunk_size)
+PHP_HTTP_BUFFER_API size_t php_http_buffer_chunk_buffer(php_http_buffer_t **s,
+               const char *data, size_t data_len, char **chunk, size_t chunk_size)
 {
        php_http_buffer_t *storage;
        
        *chunk = NULL;
        
        if (!*s) {
-               *s = php_http_buffer_init_ex(NULL, chunk_size << 1, chunk_size ? PHP_HTTP_BUFFER_INIT_PREALLOC : 0);
+               *s = php_http_buffer_init_ex(NULL, chunk_size << 1,
+                               chunk_size ? PHP_HTTP_BUFFER_INIT_PREALLOC : 0);
        }
        storage = *s;
        
@@ -222,13 +241,15 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_chunk_buffer(php_http_buffer_t **s, c
        return 0;
 }
 
-PHP_HTTP_BUFFER_API size_t php_http_buffer_chunked_output(php_http_buffer_t **s, const char *data, size_t data_len, size_t chunk_len, php_http_buffer_pass_func_t passout, void *opaque TSRMLS_DC)
+PHP_HTTP_BUFFER_API size_t php_http_buffer_chunked_output(php_http_buffer_t **s,
+               const char *data, size_t data_len, size_t chunk_len,
+               php_http_buffer_pass_func_t passout, void *opaque)
 {
        char *chunk = NULL;
        size_t passed = 0, got = 0;
 
        while ((got = php_http_buffer_chunk_buffer(s, data, data_len, &chunk, chunk_len))) {
-               if (PHP_HTTP_BUFFER_PASS0 == passout(opaque, chunk, got TSRMLS_CC)) {
+               if (PHP_HTTP_BUFFER_PASS0 == passout(opaque, chunk, got)) {
                        PTR_SET(chunk, NULL);
                        return PHP_HTTP_BUFFER_PASS0;
                }
@@ -246,15 +267,19 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_chunked_output(php_http_buffer_t **s,
        return passed;
 }
 
-PHP_HTTP_BUFFER_API ssize_t php_http_buffer_passthru(php_http_buffer_t **s, size_t chunk_size, php_http_buffer_pass_func_t passin, void *passin_arg, php_http_buffer_pass_func_t passon, void *passon_arg TSRMLS_DC)
+PHP_HTTP_BUFFER_API ssize_t php_http_buffer_passthru(php_http_buffer_t **s, size_t chunk_size,
+               php_http_buffer_pass_func_t passin, void *passin_arg,
+               php_http_buffer_pass_func_t passon, void *passon_arg)
 {
-       size_t passed_on = 0, passed_in = php_http_buffer_chunked_input(s, chunk_size, passin, passin_arg TSRMLS_CC);
+       size_t passed_on = 0, passed_in;
+
+       passed_in = php_http_buffer_chunked_input(s, chunk_size, passin, passin_arg);
 
        if (passed_in == PHP_HTTP_BUFFER_PASS0) {
                return passed_in;
        }
        if (passed_in || (*s)->used) {
-               passed_on = passon(passon_arg, (*s)->data, (*s)->used TSRMLS_CC);
+               passed_on = passon(passon_arg, (*s)->data, (*s)->used);
 
                if (passed_on == PHP_HTTP_BUFFER_PASS0) {
                        return passed_on;
@@ -268,18 +293,20 @@ PHP_HTTP_BUFFER_API ssize_t php_http_buffer_passthru(php_http_buffer_t **s, size
        return passed_on - passed_in;
 }
 
-PHP_HTTP_BUFFER_API size_t php_http_buffer_chunked_input(php_http_buffer_t **s, size_t chunk_size, php_http_buffer_pass_func_t passin, void *opaque TSRMLS_DC)
+PHP_HTTP_BUFFER_API size_t php_http_buffer_chunked_input(php_http_buffer_t **s,
+               size_t chunk_size, php_http_buffer_pass_func_t passin, void *opaque)
 {
        php_http_buffer_t *str;
        size_t passed;
 
        if (!*s) {
-               *s = php_http_buffer_init_ex(NULL, chunk_size, chunk_size ? PHP_HTTP_BUFFER_INIT_PREALLOC : 0);
+               *s = php_http_buffer_init_ex(NULL, chunk_size,
+                               chunk_size ? PHP_HTTP_BUFFER_INIT_PREALLOC : 0);
        }
        str = *s;
 
        php_http_buffer_resize(str, chunk_size);
-       passed = passin(opaque, str->data + str->used, chunk_size TSRMLS_CC);
+       passed = passin(opaque, str->data + str->used, chunk_size);
 
        if (passed != PHP_HTTP_BUFFER_PASS0) {
                str->used += passed;
@@ -293,7 +320,8 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_chunked_input(php_http_buffer_t **s,
 
 #ifdef PHP_HTTP_BUFFER_EXTENDED
 
-PHP_HTTP_BUFFER_API int php_http_buffer_cmp(php_http_buffer_t *left, php_http_buffer_t *right)
+PHP_HTTP_BUFFER_API int php_http_buffer_cmp(php_http_buffer_t *left,
+               php_http_buffer_t *right)
 {
        if (left->used > right->used) {
                return -1;
@@ -304,7 +332,8 @@ PHP_HTTP_BUFFER_API int php_http_buffer_cmp(php_http_buffer_t *left, php_http_bu
        }
 }
 
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_copy(const php_http_buffer_t *from, php_http_buffer_t *to)
+PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_copy(
+               const php_http_buffer_t *from, php_http_buffer_t *to)
 {
        int free_to = !to;
 
@@ -320,7 +349,8 @@ PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_copy(const php_http_buffe
        return to;
 }
 
-PHP_HTTP_BUFFER_API size_t php_http_buffer_insert(php_http_buffer_t *buf, const char *insert, size_t insert_len, size_t offset)
+PHP_HTTP_BUFFER_API size_t php_http_buffer_insert(php_http_buffer_t *buf,
+               const char *insert, size_t insert_len, size_t offset)
 {
        if (PHP_HTTP_BUFFER_NOMEM == php_http_buffer_resize(buf, insert_len)) {
                return PHP_HTTP_BUFFER_NOMEM;
@@ -332,7 +362,8 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_insert(php_http_buffer_t *buf, const
        return insert_len;
 }
 
-PHP_HTTP_BUFFER_API size_t php_http_buffer_insertf(php_http_buffer_t *buf, size_t offset, const char *format, ...)
+PHP_HTTP_BUFFER_API size_t php_http_buffer_insertf(php_http_buffer_t *buf,
+               size_t offset, const char *format, ...)
 {
        va_list argv;
        char *insert;
@@ -351,7 +382,8 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_insertf(php_http_buffer_t *buf, size_
        return insert_len;
 }
 
-PHP_HTTP_BUFFER_API size_t php_http_buffer_prepend(php_http_buffer_t *buf, const char *prepend, size_t prepend_len)
+PHP_HTTP_BUFFER_API size_t php_http_buffer_prepend(php_http_buffer_t *buf,
+               const char *prepend, size_t prepend_len)
 {
        if (PHP_HTTP_BUFFER_NOMEM == php_http_buffer_resize(buf, prepend_len)) {
                return PHP_HTTP_BUFFER_NOMEM;
@@ -363,7 +395,8 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_prepend(php_http_buffer_t *buf, const
        return prepend_len;
 }
 
-PHP_HTTP_BUFFER_API size_t php_http_buffer_prependf(php_http_buffer_t *buf, const char *format, ...)
+PHP_HTTP_BUFFER_API size_t php_http_buffer_prependf(php_http_buffer_t *buf,
+               const char *format, ...)
 {
        va_list argv;
        char *prepend;
@@ -382,13 +415,20 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_prependf(php_http_buffer_t *buf, cons
        return prepend_len;
 }
 
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_sub(const php_http_buffer_t *buf, size_t offset, size_t length)
+PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_sub(
+               const php_http_buffer_t *buf, size_t offset, size_t length)
 {
        if (offset >= buf->used) {
                return NULL;
        } else {
-               size_t need = 1 + ((length + offset) > buf->used ? (buf->used - offset) : (length - offset));
-               php_http_buffer_t *sub = php_http_buffer_init_ex(NULL, need, PHP_HTTP_BUFFER_INIT_PREALLOC | (buf->pmem ? PHP_HTTP_BUFFER_INIT_PERSISTENT:0));
+               php_http_buffer_t *sub;
+               size_t need = 1 + ((length + offset) > buf->used ?
+                               (buf->used - offset) : (length - offset));
+               unsigned flags = buf->pmem ? PHP_HTTP_BUFFER_INIT_PERSISTENT : 0;
+
+               sub = php_http_buffer_init_ex(NULL, need,
+                               PHP_HTTP_BUFFER_INIT_PREALLOC | flags);
+
                if (sub) {
                        if (PHP_HTTP_BUFFER_NOMEM == php_http_buffer_append(sub, buf->data + offset, need)) {
                                php_http_buffer_free(&sub);
@@ -400,7 +440,8 @@ PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_sub(const php_http_buffer
        }
 }
 
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_right(const php_http_buffer_t *buf, size_t length)
+PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_right(
+               const php_http_buffer_t *buf, size_t length)
 {
        if (length < buf->used) {
                return php_http_buffer_sub(buf, buf->used - length, length);
@@ -410,7 +451,8 @@ PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_right(const php_http_buff
 }
 
 
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_merge_va(php_http_buffer_t *buf, unsigned argc, va_list argv)
+PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_merge_va(
+               php_http_buffer_t *buf, unsigned argc, va_list argv)
 {
        unsigned i = 0;
        buf = php_http_buffer_init(buf);
@@ -427,7 +469,8 @@ PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_merge_va(php_http_buffer_
        return buf;
 }
 
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_merge_ex(php_http_buffer_t *buf, unsigned argc, ...)
+PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_merge_ex(
+               php_http_buffer_t *buf, unsigned argc, ...)
 {
        va_list argv;
        php_http_buffer_t *ret;
index faf8992..818c443 100644 (file)
                PTR = SET; \
        }
 #endif
-#ifndef TSRMLS_D
-#      define TSRMLS_D
-#      define TSRMLS_DC
-#      define TSRMLS_CC
-#      define TSRMLS_C
-#endif
 #ifdef PHP_ATTRIBUTE_FORMAT
 #      define PHP_HTTP_BUFFER_ATTRIBUTE_FORMAT(f, a, b) PHP_ATTRIBUTE_FORMAT(f, a, b)
 #else
@@ -84,7 +78,7 @@ static inline void *estrndup(void *p, size_t s)
        case PHP_HTTP_BUFFER_FREE_NOT: \
                break; \
        case PHP_HTTP_BUFFER_FREE_PTR: \
-               pefree(STR, STR->pmem); break; \
+               pefree(STR, STR->pmem); \
                break; \
        case PHP_HTTP_BUFFER_FREE_VAL: \
                php_http_buffer_dtor(STR); \
@@ -142,7 +136,7 @@ typedef enum php_http_buffer_free {
 #define php_http_buffer_new() php_http_buffer_init(NULL)
 #define php_http_buffer_init(b) php_http_buffer_init_ex(b, PHP_HTTP_BUFFER_DEFAULT_SIZE, 0)
 #define php_http_buffer_clone(from, to) php_http_buffer_init_ex((to), (from)->size, (from)->pmem ? PHP_HTTP_BUFFER_INIT_PERSISTENT:0)
-PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_init_ex(php_http_buffer_t *buf, size_t chunk_size, int flags);
+PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_init_ex(php_http_buffer_t *buf, size_t chunk_size, unsigned flags);
 
 /* create a php_http_buffer_t from a zval or c-string */
 #define php_http_buffer_from_zval(z) php_http_buffer_from_string(Z_STRVAL(z), Z_STRLEN(z))
@@ -152,7 +146,7 @@ PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_from_string_ex(php_http_b
 
 /* usually only called from within the internal functions */
 #define php_http_buffer_resize(b, s) php_http_buffer_resize_ex((b), (s), 0, 0)
-PHP_HTTP_BUFFER_API size_t php_http_buffer_resize_ex(php_http_buffer_t *buf, size_t len, size_t override_size, int allow_error);
+PHP_HTTP_BUFFER_API size_t php_http_buffer_resize_ex(php_http_buffer_t *buf, size_t len, size_t override_size, zend_bool allow_error);
 
 PHP_HTTP_BUFFER_API char *php_http_buffer_account(php_http_buffer_t *buf, size_t to_account);
 
@@ -162,6 +156,7 @@ PHP_HTTP_BUFFER_API size_t php_http_buffer_shrink(php_http_buffer_t *buf);
 /* append data to the php_http_buffer_t */
 #define php_http_buffer_appends(b, a) php_http_buffer_append((b), (a), sizeof(a)-1)
 #define php_http_buffer_appendl(b, a) php_http_buffer_append((b), (a), strlen(a))
+#define php_http_buffer_appendz(b, z) php_http_buffer_append((b), (z)->val, (z)->len)
 PHP_HTTP_BUFFER_API size_t php_http_buffer_append(php_http_buffer_t *buf, const char *append, size_t append_len);
 PHP_HTTP_BUFFER_API size_t php_http_buffer_appendf(php_http_buffer_t *buf, const char *format, ...) PHP_HTTP_BUFFER_ATTRIBUTE_FORMAT(printf, 2, 3);
 
@@ -186,15 +181,15 @@ PHP_HTTP_BUFFER_API void php_http_buffer_free(php_http_buffer_t **buf);
 /* stores data in a php_http_buffer_t until it reaches chunk_size */
 PHP_HTTP_BUFFER_API size_t php_http_buffer_chunk_buffer(php_http_buffer_t **s, const char *data, size_t data_len, char **chunk, size_t chunk_size);
 
-typedef size_t (*php_http_buffer_pass_func_t)(void *opaque, char *, size_t TSRMLS_DC);
+typedef size_t (*php_http_buffer_pass_func_t)(void *opaque, char *, size_t);
 
-PHP_HTTP_BUFFER_API ssize_t php_http_buffer_passthru(php_http_buffer_t **s, size_t chunk_size, php_http_buffer_pass_func_t passin, void *passin_arg, php_http_buffer_pass_func_t passon, void *passon_arg TSRMLS_DC);
+PHP_HTTP_BUFFER_API ssize_t php_http_buffer_passthru(php_http_buffer_t **s, size_t chunk_size, php_http_buffer_pass_func_t passin, void *passin_arg, php_http_buffer_pass_func_t passon, void *passon_arg);
 
 /* wrapper around php_http_buffer_chunk_buffer, which passes available chunks to passthru() */
-PHP_HTTP_BUFFER_API size_t php_http_buffer_chunked_output(php_http_buffer_t **s, const char *data, size_t data_len, size_t chunk_size, php_http_buffer_pass_func_t passout, void *opaque TSRMLS_DC);
+PHP_HTTP_BUFFER_API size_t php_http_buffer_chunked_output(php_http_buffer_t **s, const char *data, size_t data_len, size_t chunk_size, php_http_buffer_pass_func_t passout, void *opaque);
 
 /* write chunks directly into php_http_buffer_t buffer */
-PHP_HTTP_BUFFER_API size_t php_http_buffer_chunked_input(php_http_buffer_t **s, size_t chunk_size, php_http_buffer_pass_func_t passin, void *opaque TSRMLS_DC);
+PHP_HTTP_BUFFER_API size_t php_http_buffer_chunked_input(php_http_buffer_t **s, size_t chunk_size, php_http_buffer_pass_func_t passin, void *opaque);
 
 
 #      ifdef PHP_HTTP_BUFFER_EXTENDED
index f96164b..504e961 100644 (file)
  */
 static HashTable php_http_client_drivers;
 
-STATUS php_http_client_driver_add(php_http_client_driver_t *driver)
+ZEND_RESULT_CODE php_http_client_driver_add(php_http_client_driver_t *driver)
 {
        return zend_hash_add(&php_http_client_drivers, driver->name_str, driver->name_len + 1, (void *) driver, sizeof(php_http_client_driver_t), NULL);
 }
 
-STATUS php_http_client_driver_get(const char *name_str, size_t name_len, php_http_client_driver_t *driver)
+ZEND_RESULT_CODE php_http_client_driver_get(const char *name_str, size_t name_len, php_http_client_driver_t *driver)
 {
        php_http_client_driver_t *tmp;
 
@@ -216,7 +216,7 @@ void php_http_client_free(php_http_client_t **h) {
        }
 }
 
-STATUS php_http_client_enqueue(php_http_client_t *h, php_http_client_enqueue_t *enqueue)
+ZEND_RESULT_CODE php_http_client_enqueue(php_http_client_t *h, php_http_client_enqueue_t *enqueue)
 {
        TSRMLS_FETCH_FROM_CTX(h->ts);
 
@@ -231,7 +231,7 @@ STATUS php_http_client_enqueue(php_http_client_t *h, php_http_client_enqueue_t *
        return FAILURE;
 }
 
-STATUS php_http_client_dequeue(php_http_client_t *h, php_http_message_t *request)
+ZEND_RESULT_CODE php_http_client_dequeue(php_http_client_t *h, php_http_message_t *request)
 {
        TSRMLS_FETCH_FROM_CTX(h->ts);
 
@@ -267,7 +267,7 @@ php_http_client_enqueue_t *php_http_client_enqueued(php_http_client_t *h, void *
        return el ? (php_http_client_enqueue_t *) el->data : NULL;
 }
 
-STATUS php_http_client_wait(php_http_client_t *h, struct timeval *custom_timeout)
+ZEND_RESULT_CODE php_http_client_wait(php_http_client_t *h, struct timeval *custom_timeout)
 {
        if (h->ops->wait) {
                return h->ops->wait(h, custom_timeout);
@@ -285,7 +285,7 @@ int php_http_client_once(php_http_client_t *h)
        return FAILURE;
 }
 
-STATUS php_http_client_exec(php_http_client_t *h)
+ZEND_RESULT_CODE php_http_client_exec(php_http_client_t *h)
 {
        if (h->ops->exec) {
                return h->ops->exec(h);
@@ -304,7 +304,7 @@ void php_http_client_reset(php_http_client_t *h)
        zend_llist_clean(&h->responses);
 }
 
-STATUS php_http_client_setopt(php_http_client_t *h, php_http_client_setopt_opt_t opt, void *arg)
+ZEND_RESULT_CODE php_http_client_setopt(php_http_client_t *h, php_http_client_setopt_opt_t opt, void *arg)
 {
        if (h->ops->setopt) {
                return h->ops->setopt(h, opt, arg);
@@ -313,7 +313,7 @@ STATUS php_http_client_setopt(php_http_client_t *h, php_http_client_setopt_opt_t
        return FAILURE;
 }
 
-STATUS php_http_client_getopt(php_http_client_t *h, php_http_client_getopt_opt_t opt, void *arg, void *res_ptr)
+ZEND_RESULT_CODE php_http_client_getopt(php_http_client_t *h, php_http_client_getopt_opt_t opt, void *arg, void *res_ptr)
 {
        if (h->ops->getopt) {
                return h->ops->getopt(h, opt, arg, res_ptr);
@@ -361,7 +361,9 @@ zend_object_value php_http_client_object_new(zend_class_entry *ce TSRMLS_DC)
 static void handle_history(zval *zclient, php_http_message_t *request, php_http_message_t *response TSRMLS_DC)
 {
        zval *new_hist, *old_hist = zend_read_property(php_http_client_class_entry, zclient, ZEND_STRL("history"), 0 TSRMLS_CC);
-       php_http_message_t *zipped = php_http_message_zip(response, request);
+       php_http_message_t *req_copy = php_http_message_copy(request, NULL);
+       php_http_message_t *res_copy = php_http_message_copy(response, NULL);
+       php_http_message_t *zipped = php_http_message_zip(res_copy, req_copy);
        zend_object_value ov = php_http_message_object_new_ex(php_http_message_class_entry, zipped, NULL TSRMLS_CC);
 
        MAKE_STD_ZVAL(new_hist);
@@ -375,7 +377,7 @@ static void handle_history(zval *zclient, php_http_message_t *request, php_http_
        zval_ptr_dtor(&new_hist);
 }
 
-static STATUS handle_response(void *arg, php_http_client_t *client, php_http_client_enqueue_t *e, php_http_message_t **request, php_http_message_t **response)
+static ZEND_RESULT_CODE handle_response(void *arg, php_http_client_t *client, php_http_client_enqueue_t *e, php_http_message_t **request, php_http_message_t **response)
 {
        zend_bool dequeue = 0;
        zval zclient;
index 6c45516..d230fed 100644 (file)
@@ -38,13 +38,13 @@ typedef struct php_http_client *(*php_http_client_init_func_t)(struct php_http_c
 typedef struct php_http_client *(*php_http_client_copy_func_t)(struct php_http_client *from, struct php_http_client *to);
 typedef void (*php_http_client_dtor_func_t)(struct php_http_client *p);
 typedef void (*php_http_client_reset_func_t)(struct php_http_client *p);
-typedef STATUS (*php_http_client_exec_func_t)(struct php_http_client *p);
+typedef ZEND_RESULT_CODE (*php_http_client_exec_func_t)(struct php_http_client *p);
 typedef int (*php_http_client_once_func_t)(struct php_http_client *p);
-typedef STATUS (*php_http_client_wait_func_t)(struct php_http_client *p, struct timeval *custom_timeout);
-typedef STATUS (*php_http_client_enqueue_func_t)(struct php_http_client *p, php_http_client_enqueue_t *enqueue);
-typedef STATUS (*php_http_client_dequeue_func_t)(struct php_http_client *p, php_http_client_enqueue_t *enqueue);
-typedef STATUS (*php_http_client_setopt_func_t)(struct php_http_client *p, php_http_client_setopt_opt_t opt, void *arg);
-typedef STATUS (*php_http_client_getopt_func_t)(struct php_http_client *h, php_http_client_getopt_opt_t opt, void *arg, void **res);
+typedef ZEND_RESULT_CODE (*php_http_client_wait_func_t)(struct php_http_client *p, struct timeval *custom_timeout);
+typedef ZEND_RESULT_CODE (*php_http_client_enqueue_func_t)(struct php_http_client *p, php_http_client_enqueue_t *enqueue);
+typedef ZEND_RESULT_CODE (*php_http_client_dequeue_func_t)(struct php_http_client *p, php_http_client_enqueue_t *enqueue);
+typedef ZEND_RESULT_CODE (*php_http_client_setopt_func_t)(struct php_http_client *p, php_http_client_setopt_opt_t opt, void *arg);
+typedef ZEND_RESULT_CODE (*php_http_client_getopt_func_t)(struct php_http_client *h, php_http_client_getopt_opt_t opt, void *arg, void **res);
 
 typedef struct php_http_client_ops {
        php_resource_factory_ops_t *rsrc;
@@ -67,8 +67,8 @@ typedef struct php_http_client_driver {
        php_http_client_ops_t *client_ops;
 } php_http_client_driver_t;
 
-PHP_HTTP_API STATUS php_http_client_driver_add(php_http_client_driver_t *driver);
-PHP_HTTP_API STATUS php_http_client_driver_get(const char *name_str, size_t name_len, php_http_client_driver_t *driver);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_client_driver_add(php_http_client_driver_t *driver);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_client_driver_get(const char *name_str, size_t name_len, php_http_client_driver_t *driver);
 
 typedef struct php_http_client_progress_state {
        struct {
@@ -84,7 +84,7 @@ typedef struct php_http_client_progress_state {
        unsigned finished:1;
 } php_http_client_progress_state_t;
 
-typedef STATUS (*php_http_client_response_callback_t)(void *arg, struct php_http_client *client, php_http_client_enqueue_t *e, php_http_message_t **request, php_http_message_t **response);
+typedef ZEND_RESULT_CODE (*php_http_client_response_callback_t)(void *arg, struct php_http_client *client, php_http_client_enqueue_t *e, php_http_message_t **request, php_http_message_t **response);
 typedef void (*php_http_client_progress_callback_t)(void *arg, struct php_http_client *client, php_http_client_enqueue_t *e, php_http_client_progress_state_t *state);
 
 typedef struct php_http_client {
@@ -125,17 +125,17 @@ PHP_HTTP_API php_http_client_t *php_http_client_copy(php_http_client_t *from, ph
 PHP_HTTP_API void php_http_client_dtor(php_http_client_t *h);
 PHP_HTTP_API void php_http_client_free(php_http_client_t **h);
 
-PHP_HTTP_API STATUS php_http_client_enqueue(php_http_client_t *h, php_http_client_enqueue_t *enqueue);
-PHP_HTTP_API STATUS php_http_client_dequeue(php_http_client_t *h, php_http_message_t *request);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_client_enqueue(php_http_client_t *h, php_http_client_enqueue_t *enqueue);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_client_dequeue(php_http_client_t *h, php_http_message_t *request);
 
-PHP_HTTP_API STATUS php_http_client_wait(php_http_client_t *h, struct timeval *custom_timeout);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_client_wait(php_http_client_t *h, struct timeval *custom_timeout);
 PHP_HTTP_API int php_http_client_once(php_http_client_t *h);
 
-PHP_HTTP_API STATUS php_http_client_exec(php_http_client_t *h);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_client_exec(php_http_client_t *h);
 PHP_HTTP_API void php_http_client_reset(php_http_client_t *h);
 
-PHP_HTTP_API STATUS php_http_client_setopt(php_http_client_t *h, php_http_client_setopt_opt_t opt, void *arg);
-PHP_HTTP_API STATUS php_http_client_getopt(php_http_client_t *h, php_http_client_getopt_opt_t opt, void *arg, void *res_ptr);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_client_setopt(php_http_client_t *h, php_http_client_setopt_opt_t opt, void *arg);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_client_getopt(php_http_client_t *h, php_http_client_getopt_opt_t opt, void *arg, void *res_ptr);
 
 typedef int (*php_http_client_enqueue_cmp_func_t)(php_http_client_enqueue_t *cmp, void *arg);
 /* compare with request message pointer if compare_func is NULL */
index b057216..8304b30 100644 (file)
@@ -344,7 +344,7 @@ static int php_http_curle_dummy_callback(char *data, size_t n, size_t l, void *s
        return n*l;
 }
 
-static STATUS php_http_curle_get_info(CURL *ch, HashTable *info)
+static ZEND_RESULT_CODE php_http_curle_get_info(CURL *ch, HashTable *info)
 {
        char *c;
        long l;
@@ -805,7 +805,7 @@ static php_http_options_t php_http_curle_options;
 #define PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR            0x0002
 #define PHP_HTTP_CURLE_OPTION_TRANSFORM_MS             0x0004
 
-static STATUS php_http_curle_option_set_ssl_verifyhost(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_ssl_verifyhost(php_http_option_t *opt, zval *val, void *userdata)
 {
        php_http_client_curl_handler_t *curl = userdata;
        CURL *ch = curl->handle;
@@ -816,7 +816,7 @@ static STATUS php_http_curle_option_set_ssl_verifyhost(php_http_option_t *opt, z
        return SUCCESS;
 }
 
-static STATUS php_http_curle_option_set_cookiestore(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_cookiestore(php_http_option_t *opt, zval *val, void *userdata)
 {
        php_http_client_curl_handler_t *curl = userdata;
        CURL *ch = curl->handle;
@@ -838,7 +838,7 @@ static STATUS php_http_curle_option_set_cookiestore(php_http_option_t *opt, zval
        return SUCCESS;
 }
 
-static STATUS php_http_curle_option_set_cookies(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_cookies(php_http_option_t *opt, zval *val, void *userdata)
 {
        php_http_client_curl_handler_t *curl = userdata;
        CURL *ch = curl->handle;
@@ -885,7 +885,7 @@ static STATUS php_http_curle_option_set_cookies(php_http_option_t *opt, zval *va
        return SUCCESS;
 }
 
-static STATUS php_http_curle_option_set_encodecookies(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_encodecookies(php_http_option_t *opt, zval *val, void *userdata)
 {
        php_http_client_curl_handler_t *curl = userdata;
 
@@ -893,7 +893,7 @@ static STATUS php_http_curle_option_set_encodecookies(php_http_option_t *opt, zv
        return SUCCESS;
 }
 
-static STATUS php_http_curle_option_set_lastmodified(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_lastmodified(php_http_option_t *opt, zval *val, void *userdata)
 {
        php_http_client_curl_handler_t *curl = userdata;
        CURL *ch = curl->handle;
@@ -922,7 +922,7 @@ static STATUS php_http_curle_option_set_lastmodified(php_http_option_t *opt, zva
        return SUCCESS;
 }
 
-static STATUS php_http_curle_option_set_compress(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_compress(php_http_option_t *opt, zval *val, void *userdata)
 {
        php_http_client_curl_handler_t *curl = userdata;
 
@@ -932,7 +932,7 @@ static STATUS php_http_curle_option_set_compress(php_http_option_t *opt, zval *v
        return SUCCESS;
 }
 
-static STATUS php_http_curle_option_set_etag(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_etag(php_http_option_t *opt, zval *val, void *userdata)
 {
        php_http_client_curl_handler_t *curl = userdata;
        php_http_buffer_t header;
@@ -948,7 +948,7 @@ static STATUS php_http_curle_option_set_etag(php_http_option_t *opt, zval *val,
        return SUCCESS;
 }
 
-static STATUS php_http_curle_option_set_range(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_range(php_http_option_t *opt, zval *val, void *userdata)
 {
        php_http_client_curl_handler_t *curl = userdata;
        CURL *ch = curl->handle;
@@ -992,7 +992,7 @@ static STATUS php_http_curle_option_set_range(php_http_option_t *opt, zval *val,
        return SUCCESS;
 }
 
-static STATUS php_http_curle_option_set_resume(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_resume(php_http_option_t *opt, zval *val, void *userdata)
 {
        php_http_client_curl_handler_t *curl = userdata;
        CURL *ch = curl->handle;
@@ -1006,7 +1006,7 @@ static STATUS php_http_curle_option_set_resume(php_http_option_t *opt, zval *val
        return SUCCESS;
 }
 
-static STATUS php_http_curle_option_set_retrydelay(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_retrydelay(php_http_option_t *opt, zval *val, void *userdata)
 {
        php_http_client_curl_handler_t *curl = userdata;
 
@@ -1014,7 +1014,7 @@ static STATUS php_http_curle_option_set_retrydelay(php_http_option_t *opt, zval
        return SUCCESS;
 }
 
-static STATUS php_http_curle_option_set_retrycount(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_retrycount(php_http_option_t *opt, zval *val, void *userdata)
 {
        php_http_client_curl_handler_t *curl = userdata;
 
@@ -1022,7 +1022,7 @@ static STATUS php_http_curle_option_set_retrycount(php_http_option_t *opt, zval
        return SUCCESS;
 }
 
-static STATUS php_http_curle_option_set_redirect(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_redirect(php_http_option_t *opt, zval *val, void *userdata)
 {
        php_http_client_curl_handler_t *curl = userdata;
        CURL *ch = curl->handle;
@@ -1035,7 +1035,7 @@ static STATUS php_http_curle_option_set_redirect(php_http_option_t *opt, zval *v
        return SUCCESS;
 }
 
-static STATUS php_http_curle_option_set_portrange(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_portrange(php_http_option_t *opt, zval *val, void *userdata)
 {
        php_http_client_curl_handler_t *curl = userdata;
        CURL *ch = curl->handle;
@@ -1074,7 +1074,7 @@ static STATUS php_http_curle_option_set_portrange(php_http_option_t *opt, zval *
 }
 
 #if PHP_HTTP_CURL_VERSION(7,21,3)
-static STATUS php_http_curle_option_set_resolve(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_option_set_resolve(php_http_option_t *opt, zval *val, void *userdata)
 {
        php_http_client_curl_handler_t *curl = userdata;
        CURL *ch = curl->handle;
@@ -1394,13 +1394,13 @@ static zval *php_http_curle_get_option(php_http_option_t *opt, HashTable *option
        return option;
 }
 
-static STATUS php_http_curle_set_option(php_http_option_t *opt, zval *val, void *userdata)
+static ZEND_RESULT_CODE php_http_curle_set_option(php_http_option_t *opt, zval *val, void *userdata)
 {
        php_http_client_curl_handler_t *curl = userdata;
        CURL *ch = curl->handle;
        zval tmp;
        CURLcode rc = CURLE_OK;
-       STATUS rv = SUCCESS;
+       ZEND_RESULT_CODE rv = SUCCESS;
        TSRMLS_FETCH_FROM_CTX(curl->client->ts);
 
        if (!val) {
@@ -1478,7 +1478,7 @@ static STATUS php_http_curle_set_option(php_http_option_t *opt, zval *val, void
 
 /* client ops */
 
-static STATUS php_http_client_curl_handler_reset(php_http_client_curl_handler_t *curl)
+static ZEND_RESULT_CODE php_http_client_curl_handler_reset(php_http_client_curl_handler_t *curl)
 {
        CURL *ch = curl->handle;
        php_http_curle_storage_t *st;
@@ -1582,7 +1582,7 @@ static php_http_client_curl_handler_t *php_http_client_curl_handler_init(php_htt
 }
 
 
-static STATUS php_http_client_curl_handler_prepare(php_http_client_curl_handler_t *curl, php_http_client_enqueue_t *enqueue)
+static ZEND_RESULT_CODE php_http_client_curl_handler_prepare(php_http_client_curl_handler_t *curl, php_http_client_enqueue_t *enqueue)
 {
        size_t body_size;
        php_http_message_t *msg = enqueue->request;
@@ -1810,7 +1810,7 @@ static php_resource_factory_t *create_rf(php_http_url_t *url TSRMLS_DC)
        return rf;
 }
 
-static STATUS php_http_client_curl_enqueue(php_http_client_t *h, php_http_client_enqueue_t *enqueue)
+static ZEND_RESULT_CODE php_http_client_curl_enqueue(php_http_client_t *h, php_http_client_enqueue_t *enqueue)
 {
        CURLMcode rs;
        php_http_client_curl_t *curl = h->ctx;
@@ -1855,7 +1855,7 @@ static STATUS php_http_client_curl_enqueue(php_http_client_t *h, php_http_client
        }
 }
 
-static STATUS php_http_client_curl_dequeue(php_http_client_t *h, php_http_client_enqueue_t *enqueue)
+static ZEND_RESULT_CODE php_http_client_curl_dequeue(php_http_client_t *h, php_http_client_enqueue_t *enqueue)
 {
        CURLMcode rs;
        php_http_client_curl_t *curl = h->ctx;
@@ -1900,7 +1900,7 @@ static inline void php_http_client_curl_get_timeout(php_http_client_curl_t *curl
 #      define SELECT_ERROR -1
 #endif
 
-static STATUS php_http_client_curl_wait(php_http_client_t *h, struct timeval *custom_timeout)
+static ZEND_RESULT_CODE php_http_client_curl_wait(php_http_client_t *h, struct timeval *custom_timeout)
 {
        int MAX;
        fd_set R, W, E;
@@ -1962,7 +1962,7 @@ static int php_http_client_curl_once(php_http_client_t *h)
 
 }
 
-static STATUS php_http_client_curl_exec(php_http_client_t *h)
+static ZEND_RESULT_CODE php_http_client_curl_exec(php_http_client_t *h)
 {
 #if PHP_HTTP_HAVE_EVENT
        php_http_client_curl_t *curl = h->ctx;
@@ -2003,7 +2003,7 @@ static STATUS php_http_client_curl_exec(php_http_client_t *h)
        return SUCCESS;
 }
 
-static STATUS php_http_client_curl_setopt(php_http_client_t *h, php_http_client_setopt_opt_t opt, void *arg)
+static ZEND_RESULT_CODE php_http_client_curl_setopt(php_http_client_t *h, php_http_client_setopt_opt_t opt, void *arg)
 {
        php_http_client_curl_t *curl = h->ctx;
 
@@ -2042,7 +2042,7 @@ static STATUS php_http_client_curl_setopt(php_http_client_t *h, php_http_client_
        return SUCCESS;
 }
 
-static STATUS php_http_client_curl_getopt(php_http_client_t *h, php_http_client_getopt_opt_t opt, void *arg, void **res)
+static ZEND_RESULT_CODE php_http_client_curl_getopt(php_http_client_t *h, php_http_client_getopt_opt_t opt, void *arg, void **res)
 {
        php_http_client_enqueue_t *enqueue;
 
index 354dfa6..a04de83 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "php_http_api.h"
 
-php_http_cookie_list_t *php_http_cookie_list_init(php_http_cookie_list_t *list TSRMLS_DC)
+php_http_cookie_list_t *php_http_cookie_list_init(php_http_cookie_list_t *list)
 {
        if (!list) {
                list = emalloc(sizeof(*list));
@@ -27,16 +27,12 @@ php_http_cookie_list_t *php_http_cookie_list_init(php_http_cookie_list_t *list T
        list->max_age = -1;
        list->flags = 0;
        
-       TSRMLS_SET_CTX(list->ts);
-
        return list;
 }
 
 php_http_cookie_list_t *php_http_cookie_list_copy(php_http_cookie_list_t *from, php_http_cookie_list_t *to)
 {
-       TSRMLS_FETCH_FROM_CTX(from->ts);
-
-       to = php_http_cookie_list_init(to TSRMLS_CC);
+       to = php_http_cookie_list_init(to);
 
        array_copy(&from->cookies, &to->cookies);
        array_copy(&from->extras, &to->extras);
@@ -72,56 +68,60 @@ void php_http_cookie_list_free(php_http_cookie_list_t **list)
        }
 }
 
-const char *php_http_cookie_list_get_cookie(php_http_cookie_list_t *list, const char *name, size_t name_len, zval **zcookie)
+const char *php_http_cookie_list_get_cookie(php_http_cookie_list_t *list, const char *name, size_t name_len, zval *zcookie)
 {
-       zval **cookie;
-       if ((SUCCESS != zend_symtable_find(&list->cookies, name, name_len + 1, (void *) &cookie)) || (Z_TYPE_PP(cookie) != IS_STRING)) {
+       zval *cookie = zend_symtable_str_find(&list->cookies, name, name_len);
+
+       if (!cookie || (Z_TYPE_P(cookie) != IS_STRING)) {
                return NULL;
        }
        if (zcookie) {
                *zcookie = *cookie;
        }
-       return Z_STRVAL_PP(cookie);
+       return Z_STRVAL_P(cookie);
 }
 
-const char *php_http_cookie_list_get_extra(php_http_cookie_list_t *list, const char *name, size_t name_len, zval **zextra)
+const char *php_http_cookie_list_get_extra(php_http_cookie_list_t *list, const char *name, size_t name_len, zval *zextra)
 {
-       zval **extra;
+       zval *extra = zend_symtable_str_find(&list->extras, name, name_len);
 
-       if ((SUCCESS != zend_symtable_find(&list->extras, name, name_len + 1, (void *) &extra)) || (Z_TYPE_PP(extra) != IS_STRING)) {
+       if (!extra || (Z_TYPE_P(extra) != IS_STRING)) {
                return NULL;
        }
        if (zextra) {
                *zextra = *extra;
        }
-       return Z_STRVAL_PP(extra);
+       return Z_STRVAL_P(extra);
 }
 
 void php_http_cookie_list_add_cookie(php_http_cookie_list_t *list, const char *name, size_t name_len, const char *value, size_t value_len)
 {
-       zval *cookie_value;
+       zval cookie_value;
 
-       MAKE_STD_ZVAL(cookie_value);
-       ZVAL_STRINGL(cookie_value, estrndup(value, value_len), value_len, 0);
-       zend_symtable_update(&list->cookies, name, name_len + 1, (void *) &cookie_value, sizeof(zval *), NULL);
+       ZVAL_STRINGL(&cookie_value, value, value_len);
+       zend_symtable_str_update(&list->cookies, name, name_len, &cookie_value);
 }
 
 void php_http_cookie_list_add_extra(php_http_cookie_list_t *list, const char *name, size_t name_len, const char *value, size_t value_len)
 {
-       zval *cookie_value;
+       zval extra_value;
 
-       MAKE_STD_ZVAL(cookie_value);
-       ZVAL_STRINGL(cookie_value, estrndup(value, value_len), value_len, 0);
-       zend_symtable_update(&list->extras, name, name_len + 1, (void *) &cookie_value, sizeof(zval *), NULL);
+       ZVAL_STRINGL(&extra_value, value, value_len);
+       zend_symtable_str_update(&list->extras, name, name_len, &extra_value);
 }
 
-#define _KEY_IS(s) (key->len == sizeof(s) && !strncasecmp(key->str, (s), key->len))
-static void add_entry(php_http_cookie_list_t *list, char **allowed_extras, long flags, php_http_array_hashkey_t *key, zval *val)
+#define _KEY_IS(s) (key->key && key->key->len == sizeof(s)-1 && !strncasecmp(key->key->val, (s), key->key->len))
+static void add_entry(php_http_cookie_list_t *list, char **allowed_extras, long flags, zend_hash_key *key, zval *val)
 {
-       zval *arg = php_http_zsep(1, IS_STRING, val);
+       zval *arg = val;
+
+       Z_TRY_ADDREF_P(arg);
+       SEPARATE_ZVAL(arg);
+       convert_to_string(arg);
 
        if (!(flags & PHP_HTTP_COOKIE_PARSE_RAW)) {
                Z_STRLEN_P(arg) = php_raw_url_decode(Z_STRVAL_P(arg), Z_STRLEN_P(arg));
+               zend_string_forget_hash_val(Z_STR_P(arg));
        }
 
        if _KEY_IS("path") {
@@ -139,65 +139,63 @@ static void add_entry(php_http_cookie_list_t *list, char **allowed_extras, long
        } else if _KEY_IS("httpOnly") {
                list->flags |= PHP_HTTP_COOKIE_HTTPONLY;
        } else {
+               php_http_arrkey_t tmp = {0};
+
+               php_http_arrkey_stringify(&tmp, key);
+
                /* check for extra */
                if (allowed_extras) {
                        char **ae = allowed_extras;
-
-                       php_http_array_hashkey_stringify(key);
                        for (; *ae; ++ae) {
-                               if (!strncasecmp(key->str, *ae, key->len)) {
-                                       if (key->type == HASH_KEY_IS_LONG) {
-                                               zend_hash_index_update(&list->extras, key->num, (void *) &arg, sizeof(zval *), NULL);
-                                       } else {
-                                               zend_hash_update(&list->extras, key->str, key->len, (void *) &arg, sizeof(zval *), NULL);
-                                       }
-                                       php_http_array_hashkey_stringfree(key);
+                               if (!strncasecmp(*ae, tmp.key->val, tmp.key->len)) {
+                                       zend_symtable_update(&list->extras, tmp.key, arg);
+                                       php_http_arrkey_dtor(&tmp);
                                        return;
                                }
                        }
-                       php_http_array_hashkey_stringfree(key);
                }
 
                /* cookie */
-               if (key->type == HASH_KEY_IS_LONG) {
-                       zend_hash_index_update(&list->cookies, key->num, (void *) &arg, sizeof(zval *), NULL);
-               } else {
-                       zend_hash_update(&list->cookies, key->str, key->len, (void *) &arg, sizeof(zval *), NULL);
-               }
+               zend_symtable_update(&list->cookies, key->key, arg);
+
+               php_http_arrkey_dtor(&tmp);
                return;
        }
-       zval_ptr_dtor(&arg);
+
+       zval_ptr_dtor(arg);
 }
 
-php_http_cookie_list_t *php_http_cookie_list_parse(php_http_cookie_list_t *list, const char *str, size_t len, long flags, char **allowed_extras TSRMLS_DC)
+php_http_cookie_list_t *php_http_cookie_list_parse(php_http_cookie_list_t *list, const char *str, size_t len, long flags, char **allowed_extras)
 {
        php_http_params_opts_t opts;
        HashTable params;
-       HashPosition pos1, pos2;
-       php_http_array_hashkey_t key = php_http_array_hashkey_init(0);
-       zval **param, **val, **args, **arg;
+       zend_hash_key k, arg_k;
+       zval *param, *val, *args, *arg;
 
        php_http_params_opts_default_get(&opts);
        opts.input.str = estrndup(str, len);
        opts.input.len = len;
        opts.param = NULL;
        zend_hash_init(&params, 10, NULL, ZVAL_PTR_DTOR, 0);
-       php_http_params_parse(&params, &opts TSRMLS_CC);
+       php_http_params_parse(&params, &opts);
        efree(opts.input.str);
 
-       list = php_http_cookie_list_init(list TSRMLS_CC);
-       FOREACH_HASH_KEYVAL(pos1, &params, key, param) {
-               if (Z_TYPE_PP(param) == IS_ARRAY) {
-                       if (SUCCESS == zend_hash_find(Z_ARRVAL_PP(param), ZEND_STRS("value"), (void *) &val)) {
-                               add_entry(list, NULL, flags, &key, *val);
+       list = php_http_cookie_list_init(list);
+       ZEND_HASH_FOREACH_KEY_VAL(&params, k.h, k.key, param)
+       {
+               if (Z_TYPE_P(param) == IS_ARRAY) {
+                       if ((val = zend_hash_str_find(Z_ARRVAL_P(param), ZEND_STRL("value")))) {
+                               add_entry(list, NULL, flags, &k, val);
                        }
-                       if (SUCCESS == zend_hash_find(Z_ARRVAL_PP(param), ZEND_STRS("arguments"), (void *) &args) && Z_TYPE_PP(args) == IS_ARRAY) {
-                               FOREACH_KEYVAL(pos2, *args, key, arg) {
-                                       add_entry(list, allowed_extras, flags, &key, *arg);
-                               }
+                       if ((args = zend_hash_str_find(Z_ARRVAL_P(param), ZEND_STRL("arguments"))) && Z_TYPE_P(args) == IS_ARRAY) {
+                               ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(args), arg_k.h, arg_k.key, arg) {
+                                       add_entry(list, allowed_extras, flags, &arg_k, arg);
+                               } ZEND_HASH_FOREACH_END();
                        }
                }
        }
+       ZEND_HASH_FOREACH_END();
+
        zend_hash_destroy(&params);
 
        return list;
@@ -205,81 +203,87 @@ php_http_cookie_list_t *php_http_cookie_list_parse(php_http_cookie_list_t *list,
 
 void php_http_cookie_list_to_struct(php_http_cookie_list_t *list, zval *strct)
 {
-       zval array, *cookies, *extras;
-       TSRMLS_FETCH_FROM_CTX(list->ts);
-       
-       INIT_PZVAL_ARRAY(&array, HASH_OF(strct));
+       zval cookies, extras, tmp;
+       HashTable *ht = HASH_OF(strct);
        
-       MAKE_STD_ZVAL(cookies);
-       array_init(cookies);
-       zend_hash_copy(Z_ARRVAL_P(cookies), &list->cookies, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
-       add_assoc_zval(&array, "cookies", cookies);
+       array_init_size(&cookies, zend_hash_num_elements(&list->cookies));
+       array_copy(&list->cookies, Z_ARRVAL(cookies));
+       zend_symtable_str_update(ht, ZEND_STRL("cookies"), &cookies);
        
-       MAKE_STD_ZVAL(extras);
-       array_init(extras);
-       zend_hash_copy(Z_ARRVAL_P(extras), &list->extras, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
-       add_assoc_zval(&array, "extras", extras);
+       array_init_size(&extras, zend_hash_num_elements(&list->extras));
+       array_copy(&list->extras, Z_ARRVAL(extras));
+       zend_symtable_str_update(ht, ZEND_STRL("extras"), &extras);
        
-       add_assoc_long(&array, "flags", list->flags);
-       add_assoc_long(&array, "expires", (long) list->expires);
-       add_assoc_long(&array, "max-age", (long) list->max_age);
-       add_assoc_string(&array, "path", STR_PTR(list->path), 1);
-       add_assoc_string(&array, "domain", STR_PTR(list->domain), 1);
+       ZVAL_LONG(&tmp, list->flags);
+       zend_symtable_str_update(ht, ZEND_STRL("flags"), &tmp);
+       ZVAL_LONG(&tmp, list->expires);
+       zend_symtable_str_update(ht, ZEND_STRL("expires"), &tmp);
+       ZVAL_LONG(&tmp, list->max_age);
+       zend_symtable_str_update(ht, ZEND_STRL("max-age"), &tmp);
+       ZVAL_STRING(&tmp, STR_PTR(list->path));
+       zend_symtable_str_update(ht, ZEND_STRL("path"), &tmp);
+       ZVAL_STRING(&tmp, STR_PTR(list->domain));
+       zend_symtable_str_update(ht, ZEND_STRL("domain"), &tmp);
 }
 
-php_http_cookie_list_t *php_http_cookie_list_from_struct(php_http_cookie_list_t *list, zval *strct TSRMLS_DC)
+php_http_cookie_list_t *php_http_cookie_list_from_struct(php_http_cookie_list_t *list, zval *strct)
 {
-       zval **tmp, *cpy;
-       HashTable *ht = HASH_OF(strct);
-       
-       list = php_http_cookie_list_init(list TSRMLS_CC);
-       
-       if (SUCCESS == zend_hash_find(ht, "cookies", sizeof("cookies"), (void *) &tmp) && Z_TYPE_PP(tmp) == IS_ARRAY) {
-               zend_hash_copy(&list->cookies, Z_ARRVAL_PP(tmp), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
+       zval *tmp;
+       HashTable *ht;
+
+       ht = HASH_OF(strct);
+       list = php_http_cookie_list_init(list);
+
+       if ((tmp = zend_hash_str_find(ht, ZEND_STRL("cookies"))) && Z_TYPE_P(tmp) == IS_ARRAY){
+               array_copy(Z_ARRVAL_P(tmp), &list->cookies);
        }
-       if (SUCCESS == zend_hash_find(ht, "extras", sizeof("extras"), (void *) &tmp) && Z_TYPE_PP(tmp) == IS_ARRAY) {
-               zend_hash_copy(&list->extras, Z_ARRVAL_PP(tmp), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
+       if ((tmp = zend_hash_str_find(ht, ZEND_STRL("extras"))) && Z_TYPE_P(tmp) == IS_ARRAY){
+               array_copy(Z_ARRVAL_P(tmp), &list->extras);
        }
-       if (SUCCESS == zend_hash_find(ht, "flags", sizeof("flags"), (void *) &tmp)) {
-               cpy = php_http_ztyp(IS_LONG, *tmp);
-               list->flags = Z_LVAL_P(cpy);
-               zval_ptr_dtor(&cpy);
+       if ((tmp = zend_hash_str_find(ht, ZEND_STRL("flags")))) {
+               list->flags = zval_get_long(tmp);
        }
-       if (SUCCESS == zend_hash_find(ht, "expires", sizeof("expires"), (void *) &tmp)) {
-               if (Z_TYPE_PP(tmp) == IS_LONG) {
-                       list->expires = Z_LVAL_PP(tmp);
+       if ((tmp = zend_hash_str_find(ht, ZEND_STRL("expires")))) {
+               if (Z_TYPE_P(tmp) == IS_LONG) {
+                       list->expires = Z_LVAL_P(tmp);
                } else {
-                       long lval;
+                       zend_long lval;
+                       zend_string *lstr = zval_get_string(tmp);
 
-                       cpy = php_http_ztyp(IS_STRING, *tmp);
-                       if (IS_LONG == is_numeric_string(Z_STRVAL_P(cpy), Z_STRLEN_P(cpy), &lval, NULL, 0)) {
+                       if (IS_LONG == is_numeric_string(lstr->val, lstr->len, &lval, NULL, 0)) {
                                list->expires = lval;
                        } else {
-                               list->expires = php_parse_date(Z_STRVAL_P(cpy), NULL);
+                               list->expires = php_parse_date(lstr->val, NULL);
                        }
 
-                       zval_ptr_dtor(&cpy);
+                       zend_string_release(lstr);
                }
        }
-       if (SUCCESS == zend_hash_find(ht, "max-age", sizeof("max-age"), (void *) &tmp)) {
-               if (Z_TYPE_PP(tmp) == IS_LONG) {
-                       list->max_age = Z_LVAL_PP(tmp);
+       if ((tmp = zend_hash_str_find(ht, ZEND_STRL("max-age")))) {
+               if (Z_TYPE_P(tmp) == IS_LONG) {
+                       list->max_age = Z_LVAL_P(tmp);
                } else {
-                       long lval;
+                       zend_long lval;
+                       zend_string *lstr = zval_get_string(tmp);
 
-                       cpy = php_http_ztyp(IS_STRING, *tmp);
-                       if (IS_LONG == is_numeric_string(Z_STRVAL_P(cpy), Z_STRLEN_P(cpy), &lval, NULL, 0)) {
+                       if (IS_LONG == is_numeric_string(lstr->val, lstr->len, &lval, NULL, 0)) {
                                list->max_age = lval;
                        }
 
-                       zval_ptr_dtor(&cpy);
+                       zend_string_release(lstr);
                }
        }
-       if (SUCCESS == zend_hash_find(ht, "path", sizeof("path"), (void *) &tmp) && Z_TYPE_PP(tmp) == IS_STRING) {
-               list->path = estrndup(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
+       if ((tmp = zend_hash_str_find(ht, ZEND_STRL("path")))) {
+               zend_string *str = zval_get_string(tmp);
+
+               list->path = estrndup(str->val, str->len);
+               zend_string_release(str);
        }
-       if (SUCCESS == zend_hash_find(ht, "domain", sizeof("domain"), (void *) &tmp) && Z_TYPE_PP(tmp) == IS_STRING) {
-               list->domain = estrndup(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
+       if ((tmp = zend_hash_str_find(ht, ZEND_STRL("domain")))) {
+               zend_string *str = zval_get_string(tmp);
+
+               list->domain = estrndup(str->val, str->len);
+               zend_string_release(str);
        }
        
        return list;
@@ -287,40 +291,39 @@ php_http_cookie_list_t *php_http_cookie_list_from_struct(php_http_cookie_list_t
 
 static inline void append_encoded(php_http_buffer_t *buf, const char *key, size_t key_len, const char *val, size_t val_len)
 {
-       char *enc_str[2];
-       int enc_len[2];
+       zend_string *enc_str[2];
        
-       enc_str[0] = php_raw_url_encode(key, key_len, &enc_len[0]);
-       enc_str[1] = php_raw_url_encode(val, val_len, &enc_len[1]);
+       enc_str[0] = php_raw_url_encode(key, key_len);
+       enc_str[1] = php_raw_url_encode(val, val_len);
        
-       php_http_buffer_append(buf, enc_str[0], enc_len[0]);
+       php_http_buffer_append(buf, enc_str[0]->val, enc_str[0]->len);
        php_http_buffer_appends(buf, "=");
-       php_http_buffer_append(buf, enc_str[1], enc_len[1]);
+       php_http_buffer_append(buf, enc_str[1]->val, enc_str[1]->len);
        php_http_buffer_appends(buf, "; ");
        
-       efree(enc_str[0]);
-       efree(enc_str[1]);
+       zend_string_release(enc_str[0]);
+       zend_string_release(enc_str[1]);
 }
 
 void php_http_cookie_list_to_string(php_http_cookie_list_t *list, char **str, size_t *len)
 {
        php_http_buffer_t buf;
-       zval **val;
-       php_http_array_hashkey_t key = php_http_array_hashkey_init(0);
-       HashPosition pos;
-       TSRMLS_FETCH_FROM_CTX(list->ts);
+       zend_hash_key key;
+       zval *val;
        
        php_http_buffer_init(&buf);
-       
-       FOREACH_HASH_KEYVAL(pos, &list->cookies, key, val) {
-               zval *tmp = php_http_ztyp(IS_STRING, *val);
 
-               php_http_array_hashkey_stringify(&key);
-               append_encoded(&buf, key.str, key.len-1, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
-               php_http_array_hashkey_stringfree(&key);
+       ZEND_HASH_FOREACH_KEY_VAL(&list->cookies, key.h, key.key, val)
+       {
+               zend_string *str = zval_get_string(val);
+               php_http_arrkey_t arrkey = {0};
 
-               zval_ptr_dtor(&tmp);
+               php_http_arrkey_stringify(&arrkey, &key);
+               append_encoded(&buf, arrkey.key->val, arrkey.key->len, str->val, str->len);
+               php_http_arrkey_dtor(&arrkey);
+               zend_string_release(str);
        }
+       ZEND_HASH_FOREACH_END();
        
        if (list->domain && *list->domain) {
                php_http_buffer_appendf(&buf, "domain=%s; ", list->domain);
@@ -329,23 +332,25 @@ void php_http_cookie_list_to_string(php_http_cookie_list_t *list, char **str, si
                php_http_buffer_appendf(&buf, "path=%s; ", list->path);
        }
        if (list->expires >= 0) {
-               char *date = php_format_date(ZEND_STRL(PHP_HTTP_DATE_FORMAT), list->expires, 0 TSRMLS_CC);
-               php_http_buffer_appendf(&buf, "expires=%s; ", date);
-               efree(date);
+               zend_string *date = php_format_date(ZEND_STRL(PHP_HTTP_DATE_FORMAT), list->expires, 0);
+               php_http_buffer_appendf(&buf, "expires=%s; ", date->val);
+               zend_string_release(date);
        }
        if (list->max_age >= 0) {
                php_http_buffer_appendf(&buf, "max-age=%ld; ", list->max_age);
        }
        
-       FOREACH_HASH_KEYVAL(pos, &list->extras, key, val) {
-               zval *tmp = php_http_ztyp(IS_STRING, *val);
-
-               php_http_array_hashkey_stringify(&key);
-               append_encoded(&buf, key.str, key.len-1, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
-               php_http_array_hashkey_stringfree(&key);
-
-               zval_ptr_dtor(&tmp);
+       ZEND_HASH_FOREACH_KEY_VAL(&list->extras, key.h, key.key, val)
+       {
+               zend_string *str = zval_get_string(val);
+               php_http_arrkey_t arrkey;
+
+               php_http_arrkey_stringify(&arrkey, &key);
+               append_encoded(&buf, arrkey.key->val, arrkey.key->len, str->val, str->len);
+               php_http_arrkey_dtor(&arrkey);
+               zend_string_release(str);
        }
+       ZEND_HASH_FOREACH_END();
        
        if (list->flags & PHP_HTTP_COOKIE_SECURE) {
                php_http_buffer_appends(&buf, "secure; ");
@@ -363,60 +368,56 @@ void php_http_cookie_list_to_string(php_http_cookie_list_t *list, char **str, si
 
 static zend_object_handlers php_http_cookie_object_handlers;
 
-zend_object_value php_http_cookie_object_new(zend_class_entry *ce TSRMLS_DC)
+zend_object *php_http_cookie_object_new(zend_class_entry *ce)
 {
-       return php_http_cookie_object_new_ex(ce, NULL, NULL TSRMLS_CC);
+       return &php_http_cookie_object_new_ex(ce, NULL)->zo;
 }
 
-zend_object_value php_http_cookie_object_new_ex(zend_class_entry *ce, php_http_cookie_list_t *list, php_http_cookie_object_t **ptr TSRMLS_DC)
+php_http_cookie_object_t *php_http_cookie_object_new_ex(zend_class_entry *ce, php_http_cookie_list_t *list)
 {
        php_http_cookie_object_t *o;
 
-       o = ecalloc(sizeof(*o), 1);
-       zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-       object_properties_init((zend_object *) o, ce);
+       if (!ce) {
+               ce = php_http_cookie_class_entry;
+       }
+
+       o = ecalloc(sizeof(*o) + sizeof(zval) * (ce->default_properties_count - 1), 1);
+       zend_object_std_init(&o->zo, ce);
+       object_properties_init(&o->zo, ce);
+       o->zo.handlers = &php_http_cookie_object_handlers;
 
        if (list) {
                o->list = list;
        }
 
-       if (ptr) {
-               *ptr = o;
-       }
-
-       o->zv.handle = zend_objects_store_put(o, NULL, php_http_cookie_object_free, NULL TSRMLS_CC);
-       o->zv.handlers = &php_http_cookie_object_handlers;
-
-       return o->zv;
+       return o;
 }
 
 #define PHP_HTTP_COOKIE_OBJECT_INIT(obj) \
        do { \
                if (!obj->list) { \
-                       obj->list = php_http_cookie_list_init(NULL TSRMLS_CC); \
+                       obj->list = php_http_cookie_list_init(NULL); \
                } \
        } while(0)
 
-zend_object_value php_http_cookie_object_clone(zval *this_ptr TSRMLS_DC)
+zend_object *php_http_cookie_object_clone(zval *obj)
 {
-       php_http_cookie_object_t *new_obj, *old_obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-       zend_object_value ov;
+       php_http_cookie_object_t *new_obj, *old_obj = PHP_HTTP_OBJ(NULL, obj);
 
        PHP_HTTP_COOKIE_OBJECT_INIT(old_obj);
 
-       ov = php_http_cookie_object_new_ex(old_obj->zo.ce, php_http_cookie_list_copy(old_obj->list, NULL), &new_obj TSRMLS_CC);
-       zend_objects_clone_members((zend_object *) new_obj, ov, (zend_object *) old_obj, Z_OBJ_HANDLE_P(getThis()) TSRMLS_CC);
+       new_obj = php_http_cookie_object_new_ex(old_obj->zo.ce, php_http_cookie_list_copy(old_obj->list, NULL));
+       zend_objects_clone_members(&new_obj->zo, &old_obj->zo);
 
-       return ov;
+       return &new_obj->zo;
 }
 
-void php_http_cookie_object_free(void *object TSRMLS_DC)
+void php_http_cookie_object_free(zend_object *object TSRMLS_DC)
 {
-       php_http_cookie_object_t *obj = object;
+       php_http_cookie_object_t *obj = PHP_HTTP_OBJ(object, NULL);
 
        php_http_cookie_list_free(&obj->list);
-       zend_object_std_dtor((zend_object *) obj TSRMLS_CC);
-       efree(obj);
+       zend_object_std_dtor(object);
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpCookie___construct, 0, 0, 0)
@@ -433,32 +434,33 @@ static PHP_METHOD(HttpCookie, __construct)
        HashTable *allowed_extras = NULL;
        zend_error_handling zeh;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z!lH", &zcookie, &flags, &allowed_extras), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|z!lH", &zcookie, &flags, &allowed_extras), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
-       zend_replace_error_handling(EH_THROW, php_http_exception_runtime_class_entry, &zeh TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, php_http_exception_runtime_class_entry, &zeh);
        if (zcookie) {
 
                if (allowed_extras && zend_hash_num_elements(allowed_extras)) {
                        char **ae_ptr = safe_emalloc(zend_hash_num_elements(allowed_extras) + 1, sizeof(char *), 0);
-                       HashPosition pos;
-                       zval **val;
+                       zval *val;
 
                        ae = ae_ptr;
-                       FOREACH_HASH_VAL(pos, allowed_extras, val) {
-                               zval *cpy = php_http_ztyp(IS_STRING, *val);
+                       ZEND_HASH_FOREACH_VAL(allowed_extras, val)
+                       {
+                               zend_string *str = zval_get_string(val);
 
-                               *ae_ptr++ = estrndup(Z_STRVAL_P(cpy), Z_STRLEN_P(cpy));
-                               zval_ptr_dtor(&cpy);
+                               *ae_ptr++ = estrndup(str->val, str->len);
+                               zend_string_release(str);
                        }
+                       ZEND_HASH_FOREACH_END();
                        *ae_ptr = NULL;
                }
 
                switch (Z_TYPE_P(zcookie)) {
                        case IS_OBJECT:
-                               if (instanceof_function(Z_OBJCE_P(zcookie), php_http_cookie_class_entry TSRMLS_CC)) {
-                                       php_http_cookie_object_t *zco = zend_object_store_get_object(zcookie TSRMLS_CC);
+                               if (instanceof_function(Z_OBJCE_P(zcookie), php_http_cookie_class_entry)) {
+                                       php_http_cookie_object_t *zco = PHP_HTTP_OBJ(NULL, zcookie);
 
                                        if (zco->list) {
                                                obj->list = php_http_cookie_list_copy(zco->list, NULL);
@@ -467,13 +469,13 @@ static PHP_METHOD(HttpCookie, __construct)
                                }
                                /* no break */
                        case IS_ARRAY:
-                               obj->list = php_http_cookie_list_from_struct(obj->list, zcookie TSRMLS_CC);
+                               obj->list = php_http_cookie_list_from_struct(obj->list, zcookie);
                                break;
                        default: {
-                               zval *cpy = php_http_ztyp(IS_STRING, zcookie);
+                               zend_string *str = zval_get_string(zcookie);
 
-                               obj->list = php_http_cookie_list_parse(obj->list, Z_STRVAL_P(cpy), Z_STRLEN_P(cpy), flags, ae TSRMLS_CC);
-                               zval_ptr_dtor(&cpy);
+                               obj->list = php_http_cookie_list_parse(obj->list, str->val, str->len, flags, ae);
+                               zend_string_release(str);
                                break;
                        }
                }
@@ -487,7 +489,7 @@ static PHP_METHOD(HttpCookie, __construct)
                        efree(ae);
                }
        }
-       zend_restore_error_handling(&zeh TSRMLS_CC);
+       zend_restore_error_handling(&zeh);
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 }
@@ -502,11 +504,11 @@ static PHP_METHOD(HttpCookie, getCookies)
                return;
        }
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
-       array_init(return_value);
+       array_init_size(return_value, zend_hash_num_elements(&obj->list->cookies));
        array_copy(&obj->list->cookies, Z_ARRVAL_P(return_value));
 }
 
@@ -518,9 +520,9 @@ static PHP_METHOD(HttpCookie, setCookies)
        HashTable *cookies = NULL;
        php_http_cookie_object_t *obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|H", &cookies), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|H", &cookies), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
@@ -529,7 +531,7 @@ static PHP_METHOD(HttpCookie, setCookies)
                array_copy_strings(cookies, &obj->list->cookies);
        }
 
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETURN_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpCookie_addCookies, 0, 0, 1)
@@ -540,15 +542,15 @@ static PHP_METHOD(HttpCookie, addCookies)
        HashTable *cookies = NULL;
        php_http_cookie_object_t *obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H", &cookies), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "H", &cookies), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
        array_join(cookies, &obj->list->cookies, 1, ARRAY_JOIN_STRONLY|ARRAY_JOIN_STRINGIFY);
 
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpCookie_getExtras, 0, 0, 0)
@@ -561,11 +563,11 @@ static PHP_METHOD(HttpCookie, getExtras)
                return;
        }
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
-       array_init(return_value);
+       array_init_size(return_value, zend_hash_num_elements(&obj->list->extras));
        array_copy(&obj->list->extras, Z_ARRVAL_P(return_value));
 }
 
@@ -577,9 +579,9 @@ static PHP_METHOD(HttpCookie, setExtras)
        HashTable *extras = NULL;
        php_http_cookie_object_t *obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|H", &extras), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|H", &extras), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
@@ -588,7 +590,7 @@ static PHP_METHOD(HttpCookie, setExtras)
                array_copy_strings(extras, &obj->list->extras);
        }
 
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpCookie_addExtras, 0, 0, 1)
@@ -599,15 +601,15 @@ static PHP_METHOD(HttpCookie, addExtras)
        HashTable *extras = NULL;
        php_http_cookie_object_t *obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H", &extras), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "H", &extras), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
        array_join(extras, &obj->list->extras, 1, ARRAY_JOIN_STRONLY|ARRAY_JOIN_STRINGIFY);
 
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpCookie_getCookie, 0, 0, 1)
@@ -616,20 +618,20 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpCookie, getCookie)
 {
        char *name_str;
-       int name_len;
-       zval *zvalue;
+       size_t name_len;
+       zval zvalue;
        php_http_cookie_object_t *obj;
 
-       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name_str, &name_len)) {
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len)) {
                return;
        }
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
        if (php_http_cookie_list_get_cookie(obj->list, name_str, name_len, &zvalue)) {
-               RETURN_ZVAL(zvalue, 1, 0);
+               RETURN_ZVAL_FAST(&zvalue);
        }
 }
 
@@ -640,12 +642,12 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpCookie, setCookie)
 {
        char *name_str, *value_str = NULL;
-       int name_len, value_len = 0;
+       size_t name_len, value_len = 0;
        php_http_cookie_object_t *obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!", &name_str, &name_len, &value_str, &value_len), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &name_str, &name_len, &value_str, &value_len), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
@@ -655,7 +657,7 @@ static PHP_METHOD(HttpCookie, setCookie)
                php_http_cookie_list_add_cookie(obj->list, name_str, name_len, value_str, value_len);
        }
 
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpCookie_addCookie, 0, 0, 2)
@@ -665,18 +667,18 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpCookie, addCookie)
 {
        char *name_str, *value_str;
-       int name_len, value_len;
+       size_t name_len, value_len;
        php_http_cookie_object_t *obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &name_str, &name_len, &value_str, &value_len), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &name_str, &name_len, &value_str, &value_len), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
        php_http_cookie_list_add_cookie(obj->list, name_str, name_len, value_str, value_len);
 
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpCookie_getExtra, 0, 0, 1)
@@ -685,20 +687,20 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpCookie, getExtra)
 {
        char *name_str;
-       int name_len;
-       zval *zvalue;
+       size_t name_len;
+       zval zvalue;
        php_http_cookie_object_t *obj;
 
-       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name_str, &name_len)) {
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len)) {
                return;
        }
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
        if (php_http_cookie_list_get_extra(obj->list, name_str, name_len, &zvalue)) {
-               RETURN_ZVAL(zvalue, 1, 0);
+               RETURN_ZVAL_FAST(&zvalue);
        }
 }
 
@@ -709,12 +711,12 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpCookie, setExtra)
 {
        char *name_str, *value_str = NULL;
-       int name_len, value_len = 0;
+       size_t name_len, value_len = 0;
        php_http_cookie_object_t *obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!", &name_str, &name_len, &value_str, &value_len), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &name_str, &name_len, &value_str, &value_len), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
@@ -724,7 +726,7 @@ static PHP_METHOD(HttpCookie, setExtra)
                php_http_cookie_list_add_extra(obj->list, name_str, name_len, value_str, value_len);
        }
 
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpCookie_addExtra, 0, 0, 2)
@@ -734,18 +736,18 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpCookie, addExtra)
 {
        char *name_str, *value_str;
-       int name_len, value_len;
+       size_t name_len, value_len;
        php_http_cookie_object_t *obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &name_str, &name_len, &value_str, &value_len), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &name_str, &name_len, &value_str, &value_len), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
        php_http_cookie_list_add_extra(obj->list, name_str, name_len, value_str, value_len);
 
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpCookie_getDomain, 0, 0, 0)
@@ -758,12 +760,12 @@ static PHP_METHOD(HttpCookie, getDomain)
                return;
        }
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
        if (obj->list->domain) {
-               RETURN_STRING(obj->list->domain, 1);
+               RETURN_STRING(obj->list->domain);
        }
 }
 
@@ -773,18 +775,18 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpCookie, setDomain)
 {
        char *domain_str = NULL;
-       int domain_len = 0;
+       size_t domain_len = 0;
        php_http_cookie_object_t *obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!", &domain_str, &domain_len), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|s!", &domain_str, &domain_len), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
        PTR_SET(obj->list->domain, domain_str ? estrndup(domain_str, domain_len) : NULL);
 
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpCookie_getPath, 0, 0, 0)
@@ -797,12 +799,12 @@ static PHP_METHOD(HttpCookie, getPath)
                return;
        }
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
        if (obj->list->path) {
-               RETURN_STRING(obj->list->path, 1);
+               RETURN_STRING(obj->list->path);
        }
 }
 
@@ -812,18 +814,18 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpCookie, setPath)
 {
        char *path_str = NULL;
-       int path_len = 0;
+       size_t path_len = 0;
        php_http_cookie_object_t *obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!", &path_str, &path_len), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|s!", &path_str, &path_len), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
        PTR_SET(obj->list->path, path_str ? estrndup(path_str, path_len) : NULL);
 
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpCookie_getExpires, 0, 0, 0)
@@ -836,7 +838,7 @@ static PHP_METHOD(HttpCookie, getExpires)
                return;
        }
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
@@ -851,15 +853,15 @@ static PHP_METHOD(HttpCookie, setExpires)
        long ts = -1;
        php_http_cookie_object_t *obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &ts), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &ts), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
        obj->list->expires = ts;
 
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpCookie_getMaxAge, 0, 0, 0)
@@ -872,7 +874,7 @@ static PHP_METHOD(HttpCookie, getMaxAge)
                return;
        }
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
@@ -884,18 +886,18 @@ ZEND_BEGIN_ARG_INFO_EX(ai_HttpCookie_setMaxAge, 0, 0, 0)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpCookie, setMaxAge)
 {
-       long ts = -1;
+       long ma = -1;
        php_http_cookie_object_t *obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &ts), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &ma), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
-       obj->list->max_age = ts;
+       obj->list->max_age = ma;
 
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpCookie_getFlags, 0, 0, 0)
@@ -908,7 +910,7 @@ static PHP_METHOD(HttpCookie, getFlags)
                return;
        }
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
@@ -925,13 +927,13 @@ static PHP_METHOD(HttpCookie, setFlags)
 
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
        obj->list->flags = flags;
 
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpCookie_toString, 0, 0, 0)
@@ -946,13 +948,13 @@ static PHP_METHOD(HttpCookie, toString)
                RETURN_EMPTY_STRING();
        }
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
        php_http_cookie_list_to_string(obj->list, &str, &len);
 
-       RETURN_STRINGL(str, len, 0);
+       RETURN_NEW_STR(php_http_cs2zs(str, len));
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpCookie_toArray, 0, 0, 0)
@@ -965,11 +967,11 @@ static PHP_METHOD(HttpCookie, toArray)
                return;
        }
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_COOKIE_OBJECT_INIT(obj);
 
-       array_init(return_value);
+       array_init_size(return_value, 8);
        php_http_cookie_list_to_struct(obj->list, return_value);
 }
 
@@ -1014,10 +1016,12 @@ PHP_MINIT_FUNCTION(http_cookie)
        zend_class_entry ce = {0};
 
        INIT_NS_CLASS_ENTRY(ce, "http", "Cookie", php_http_cookie_methods);
-       php_http_cookie_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
+       php_http_cookie_class_entry = zend_register_internal_class(&ce);
        php_http_cookie_class_entry->create_object = php_http_cookie_object_new;
        memcpy(&php_http_cookie_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+       php_http_cookie_object_handlers.offset = XtOffsetOf(php_http_cookie_object_t, zo);
        php_http_cookie_object_handlers.clone_obj = php_http_cookie_object_clone;
+       php_http_cookie_object_handlers.dtor_obj = php_http_cookie_object_free;
 
        zend_declare_class_constant_long(php_http_cookie_class_entry, ZEND_STRL("PARSE_RAW"), PHP_HTTP_COOKIE_PARSE_RAW TSRMLS_CC);
        zend_declare_class_constant_long(php_http_cookie_class_entry, ZEND_STRL("SECURE"), PHP_HTTP_COOKIE_SECURE TSRMLS_CC);
index 7cf00fe..9e63cbe 100644 (file)
@@ -31,44 +31,39 @@ typedef struct php_http_cookie_list {
        char *domain;
        time_t expires;
        time_t max_age;
-
-#ifdef ZTS
-       void ***ts;
-#endif
 } php_http_cookie_list_t;
 
-PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_init(php_http_cookie_list_t *list TSRMLS_DC);
-PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_parse(php_http_cookie_list_t *list, const char *str, size_t len, long flags, char **allowed_extras TSRMLS_DC);
+PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_init(php_http_cookie_list_t *list);
+PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_parse(php_http_cookie_list_t *list, const char *str, size_t len, long flags, char **allowed_extras);
 PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_copy(php_http_cookie_list_t *from, php_http_cookie_list_t *to);
 PHP_HTTP_API void php_http_cookie_list_dtor(php_http_cookie_list_t *list);
 PHP_HTTP_API void php_http_cookie_list_free(php_http_cookie_list_t **list);
 
-#define php_http_cookie_list_has_cookie(list, name, name_len) zend_symtable_exists(&(list)->cookies, (name), (name_len)+1)
-#define php_http_cookie_list_del_cookie(list, name, name_len) zend_symtable_del(&(list)->cookies, (name), (name_len)+1)
+#define php_http_cookie_list_has_cookie(list, name, name_len) zend_symtable_str_exists(&(list)->cookies, (name), (name_len))
+#define php_http_cookie_list_del_cookie(list, name, name_len) zend_symtable_str_del(&(list)->cookies, (name), (name_len))
 PHP_HTTP_API void php_http_cookie_list_add_cookie(php_http_cookie_list_t *list, const char *name, size_t name_len, const char *value, size_t value_len);
-PHP_HTTP_API const char *php_http_cookie_list_get_cookie(php_http_cookie_list_t *list, const char *name, size_t name_len, zval **cookie);
+PHP_HTTP_API const char *php_http_cookie_list_get_cookie(php_http_cookie_list_t *list, const char *name, size_t name_len, zval *cookie);
 
-#define php_http_cookie_list_has_extra(list, name, name_len) zend_symtable_exists(&(list)->extras, (name), (name_len)+1)
-#define php_http_cookie_list_del_extra(list, name, name_len) zend_symtable_del(&(list)->extras, (name), (name_len)+1)
+#define php_http_cookie_list_has_extra(list, name, name_len) zend_symtable_str_exists(&(list)->extras, (name), (name_len))
+#define php_http_cookie_list_del_extra(list, name, name_len) zend_symtable_str_del(&(list)->extras, (name), (name_len))
 PHP_HTTP_API void php_http_cookie_list_add_extra(php_http_cookie_list_t *list, const char *name, size_t name_len, const char *value, size_t value_len);
-PHP_HTTP_API const char *php_http_cookie_list_get_extra(php_http_cookie_list_t *list, const char *name, size_t name_len, zval **extra);
+PHP_HTTP_API const char *php_http_cookie_list_get_extra(php_http_cookie_list_t *list, const char *name, size_t name_len, zval *extra);
 
 PHP_HTTP_API void php_http_cookie_list_to_string(php_http_cookie_list_t *list, char **str, size_t *len);
-PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_from_struct(php_http_cookie_list_t *list, zval *strct TSRMLS_DC);
+PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_from_struct(php_http_cookie_list_t *list, zval *strct);
 PHP_HTTP_API void php_http_cookie_list_to_struct(php_http_cookie_list_t *list, zval *strct);
 
 PHP_HTTP_API zend_class_entry *php_http_cookie_class_entry;
 
 typedef struct php_http_cookie_object {
-       zend_object zo;
-       zend_object_value zv;
        php_http_cookie_list_t *list;
+       zend_object zo;
 } php_http_cookie_object_t;
 
-zend_object_value php_http_cookie_object_new(zend_class_entry *ce TSRMLS_DC);
-zend_object_value php_http_cookie_object_new_ex(zend_class_entry *ce, php_http_cookie_list_t *list, php_http_cookie_object_t **obj TSRMLS_DC);
-zend_object_value php_http_cookie_object_clone(zval *this_ptr TSRMLS_DC);
-void php_http_cookie_object_free(void *object TSRMLS_DC);
+zend_object *php_http_cookie_object_new(zend_class_entry *ce);
+php_http_cookie_object_t *php_http_cookie_object_new_ex(zend_class_entry *ce, php_http_cookie_list_t *list);
+zend_object *php_http_cookie_object_clone(zval *this_ptr);
+void php_http_cookie_object_free(zend_object *object TSRMLS_DC);
 
 PHP_MINIT_FUNCTION(http_cookie);
 
index b7050f6..a6e9337 100644 (file)
@@ -28,7 +28,7 @@ static inline int eol_match(char **line, int *eol_len)
        }
 }
 
-const char *php_http_encoding_dechunk(const char *encoded, size_t encoded_len, char **decoded, size_t *decoded_len TSRMLS_DC)
+const char *php_http_encoding_dechunk(const char *encoded, size_t encoded_len, char **decoded, size_t *decoded_len)
 {
        int eol_len = 0;
        char *n_ptr = NULL;
@@ -50,13 +50,13 @@ const char *php_http_encoding_dechunk(const char *encoded, size_t encoded_len, c
                         * not encoded data and return a copy
                         */
                        if (e_ptr == encoded) {
-                               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Data does not seem to be chunked encoded");
+                               php_error_docref(NULL, E_NOTICE, "Data does not seem to be chunked encoded");
                                memcpy(*decoded, encoded, encoded_len);
                                *decoded_len = encoded_len;
                                return encoded + encoded_len;
                        } else {
                                efree(*decoded);
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected chunk size at pos %tu of %zu but got trash", n_ptr - encoded, encoded_len);
+                               php_error_docref(NULL, E_WARNING, "Expected chunk size at pos %tu of %zu but got trash", n_ptr - encoded, encoded_len);
                                return NULL;
                        }
                }
@@ -79,16 +79,16 @@ const char *php_http_encoding_dechunk(const char *encoded, size_t encoded_len, c
                /* there should be CRLF after the chunk size, but we'll ignore SP+ too */
                if (*n_ptr && !eol_match(&n_ptr, &eol_len)) {
                        if (eol_len == 2) {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected CRLF at pos %tu of %zu but got 0x%02X 0x%02X", n_ptr - encoded, encoded_len, *n_ptr, *(n_ptr + 1));
+                               php_error_docref(NULL, E_WARNING, "Expected CRLF at pos %tu of %zu but got 0x%02X 0x%02X", n_ptr - encoded, encoded_len, *n_ptr, *(n_ptr + 1));
                        } else {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected LF at pos %tu of %zu but got 0x%02X", n_ptr - encoded, encoded_len, *n_ptr);
+                               php_error_docref(NULL, E_WARNING, "Expected LF at pos %tu of %zu but got 0x%02X", n_ptr - encoded, encoded_len, *n_ptr);
                        }
                }
                n_ptr += eol_len;
                
                /* chunk size pretends more data than we actually got, so it's probably a truncated message */
                if (chunk_len > (rest = encoded + encoded_len - n_ptr)) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Truncated message: chunk size %lu exceeds remaining data size %lu at pos %tu of %zu", chunk_len, rest, n_ptr - encoded, encoded_len);
+                       php_error_docref(NULL, E_WARNING, "Truncated message: chunk size %lu exceeds remaining data size %lu at pos %tu of %zu", chunk_len, rest, n_ptr - encoded, encoded_len);
                        chunk_len = rest;
                }
 
@@ -148,7 +148,7 @@ static inline int php_http_inflate_rounds(z_stream *Z, int flush, char **buf, si
        return status;
 }
 
-STATUS php_http_encoding_deflate(int flags, const char *data, size_t data_len, char **encoded, size_t *encoded_len TSRMLS_DC)
+ZEND_RESULT_CODE php_http_encoding_deflate(int flags, const char *data, size_t data_len, char **encoded, size_t *encoded_len)
 {
        int status, level, wbits, strategy;
        z_stream Z;
@@ -185,11 +185,11 @@ STATUS php_http_encoding_deflate(int flags, const char *data, size_t data_len, c
                }
        }
        
-       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not deflate data: %s", zError(status));
+       php_error_docref(NULL, E_WARNING, "Could not deflate data: %s", zError(status));
        return FAILURE;
 }
 
-STATUS php_http_encoding_inflate(const char *data, size_t data_len, char **decoded, size_t *decoded_len TSRMLS_DC)
+ZEND_RESULT_CODE php_http_encoding_inflate(const char *data, size_t data_len, char **decoded, size_t *decoded_len)
 {
        z_stream Z;
        int status, wbits = PHP_HTTP_WINDOW_BITS_ANY;
@@ -227,11 +227,11 @@ retry_raw_inflate:
                }
        }
        
-       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not inflate data: %s", zError(status));
+       php_error_docref(NULL, E_WARNING, "Could not inflate data: %s", zError(status));
        return FAILURE;
 }
 
-php_http_encoding_stream_t *php_http_encoding_stream_init(php_http_encoding_stream_t *s, php_http_encoding_stream_ops_t *ops, unsigned flags TSRMLS_DC)
+php_http_encoding_stream_t *php_http_encoding_stream_init(php_http_encoding_stream_t *s, php_http_encoding_stream_ops_t *ops, unsigned flags)
 {
        int freeme;
 
@@ -241,7 +241,6 @@ php_http_encoding_stream_t *php_http_encoding_stream_init(php_http_encoding_stre
        memset(s, 0, sizeof(*s));
 
        s->flags = flags;
-       TSRMLS_SET_CTX(s->ts);
 
        if ((s->ops = ops)) {
                php_http_encoding_stream_t *ss = s->ops->init(s);
@@ -261,8 +260,6 @@ php_http_encoding_stream_t *php_http_encoding_stream_init(php_http_encoding_stre
 
 php_http_encoding_stream_t *php_http_encoding_stream_copy(php_http_encoding_stream_t *from, php_http_encoding_stream_t *to)
 {
-       TSRMLS_FETCH_FROM_CTX(from->ts);
-
        if (from->ops->copy) {
                int freeme;
                php_http_encoding_stream_t *ns;
@@ -274,7 +271,6 @@ php_http_encoding_stream_t *php_http_encoding_stream_copy(php_http_encoding_stre
 
                to->flags = from->flags;
                to->ops = from->ops;
-               TSRMLS_SET_CTX(to->ts);
 
                if ((ns = to->ops->copy(from, to))) {
                        return ns;
@@ -290,9 +286,10 @@ php_http_encoding_stream_t *php_http_encoding_stream_copy(php_http_encoding_stre
        return NULL;
 }
 
-STATUS php_http_encoding_stream_reset(php_http_encoding_stream_t **s)
+ZEND_RESULT_CODE php_http_encoding_stream_reset(php_http_encoding_stream_t **s)
 {
        php_http_encoding_stream_t *ss;
+
        if ((*s)->ops->dtor) {
                (*s)->ops->dtor(*s);
        }
@@ -303,7 +300,7 @@ STATUS php_http_encoding_stream_reset(php_http_encoding_stream_t **s)
        return FAILURE;
 }
 
-STATUS php_http_encoding_stream_update(php_http_encoding_stream_t *s, const char *in_str, size_t in_len, char **out_str, size_t *out_len)
+ZEND_RESULT_CODE php_http_encoding_stream_update(php_http_encoding_stream_t *s, const char *in_str, size_t in_len, char **out_str, size_t *out_len)
 {
        if (!s->ops->update) {
                return FAILURE;
@@ -311,7 +308,7 @@ STATUS php_http_encoding_stream_update(php_http_encoding_stream_t *s, const char
        return s->ops->update(s, in_str, in_len, out_str, out_len);
 }
 
-STATUS php_http_encoding_stream_flush(php_http_encoding_stream_t *s, char **out_str, size_t *out_len)
+ZEND_RESULT_CODE php_http_encoding_stream_flush(php_http_encoding_stream_t *s, char **out_str, size_t *out_len)
 {
        if (!s->ops->flush) {
                *out_str = NULL;
@@ -329,7 +326,7 @@ zend_bool php_http_encoding_stream_done(php_http_encoding_stream_t *s)
        return s->ops->done(s);
 }
 
-STATUS php_http_encoding_stream_finish(php_http_encoding_stream_t *s, char **out_str, size_t *out_len)
+ZEND_RESULT_CODE php_http_encoding_stream_finish(php_http_encoding_stream_t *s, char **out_str, size_t *out_len)
 {
        if (!s->ops->finish) {
                *out_str = NULL;
@@ -367,7 +364,6 @@ static php_http_encoding_stream_t *deflate_init(php_http_encoding_stream_t *s)
 {
        int status, level, wbits, strategy, p = (s->flags & PHP_HTTP_ENCODING_STREAM_PERSISTENT);
        z_streamp ctx = pecalloc(1, sizeof(z_stream), p);
-       TSRMLS_FETCH_FROM_CTX(s->ts);
        
        PHP_HTTP_DEFLATE_LEVEL_SET(s->flags, level);
        PHP_HTTP_DEFLATE_WBITS_SET(s->flags, wbits);
@@ -382,7 +378,7 @@ static php_http_encoding_stream_t *deflate_init(php_http_encoding_stream_t *s)
                status = Z_MEM_ERROR;
        }
        pefree(ctx, p);
-       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to initialize deflate encoding stream: %s", zError(status));
+       php_error_docref(NULL, E_WARNING, "Failed to initialize deflate encoding stream: %s", zError(status));
        return NULL;
 }
 
@@ -390,7 +386,6 @@ static php_http_encoding_stream_t *inflate_init(php_http_encoding_stream_t *s)
 {
        int status, wbits, p = (s->flags & PHP_HTTP_ENCODING_STREAM_PERSISTENT);
        z_streamp ctx = pecalloc(1, sizeof(z_stream), p);
-       TSRMLS_FETCH_FROM_CTX(s->ts);
        
        PHP_HTTP_INFLATE_WBITS_SET(s->flags, wbits);
        
@@ -403,7 +398,7 @@ static php_http_encoding_stream_t *inflate_init(php_http_encoding_stream_t *s)
                status = Z_MEM_ERROR;
        }
        pefree(ctx, p);
-       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to initialize inflate stream: %s", zError(status));
+       php_error_docref(NULL, E_WARNING, "Failed to initialize inflate stream: %s", zError(status));
        return NULL;
 }
 
@@ -426,7 +421,6 @@ static php_http_encoding_stream_t *deflate_copy(php_http_encoding_stream_t *from
 {
        int status, p = to->flags & PHP_HTTP_ENCODING_STREAM_PERSISTENT;
        z_streamp from_ctx = from->ctx, to_ctx = pecalloc(1, sizeof(*to_ctx), p);
-       TSRMLS_FETCH_FROM_CTX(from->ts);
 
        if (Z_OK == (status = deflateCopy(to_ctx, from_ctx))) {
                if ((to_ctx->opaque = php_http_buffer_init_ex(NULL, PHP_HTTP_DEFLATE_BUFFER_SIZE, p ? PHP_HTTP_BUFFER_INIT_PERSISTENT : 0))) {
@@ -437,7 +431,7 @@ static php_http_encoding_stream_t *deflate_copy(php_http_encoding_stream_t *from
                deflateEnd(to_ctx);
                status = Z_MEM_ERROR;
        }
-       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to copy deflate encoding stream: %s", zError(status));
+       php_error_docref(NULL, E_WARNING, "Failed to copy deflate encoding stream: %s", zError(status));
        return NULL;
 }
 
@@ -445,7 +439,6 @@ static php_http_encoding_stream_t *inflate_copy(php_http_encoding_stream_t *from
 {
        int status, p = from->flags & PHP_HTTP_ENCODING_STREAM_PERSISTENT;
        z_streamp from_ctx = from->ctx, to_ctx = pecalloc(1, sizeof(*to_ctx), p);
-       TSRMLS_FETCH_FROM_CTX(from->ts);
 
        if (Z_OK == (status = inflateCopy(to_ctx, from_ctx))) {
                if ((to_ctx->opaque = php_http_buffer_init_ex(NULL, PHP_HTTP_DEFLATE_BUFFER_SIZE, p ? PHP_HTTP_BUFFER_INIT_PERSISTENT : 0))) {
@@ -456,7 +449,7 @@ static php_http_encoding_stream_t *inflate_copy(php_http_encoding_stream_t *from
                inflateEnd(to_ctx);
                status = Z_MEM_ERROR;
        }
-       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to copy inflate encoding stream: %s", zError(status));
+       php_error_docref(NULL, E_WARNING, "Failed to copy inflate encoding stream: %s", zError(status));
        return NULL;
 }
 
@@ -464,7 +457,6 @@ static php_http_encoding_stream_t *dechunk_copy(php_http_encoding_stream_t *from
 {
        int p = from->flags & PHP_HTTP_ENCODING_STREAM_PERSISTENT;
        struct dechunk_ctx *from_ctx = from->ctx, *to_ctx = pemalloc(sizeof(*to_ctx), p);
-       TSRMLS_FETCH_FROM_CTX(from->ts);
 
        if (php_http_buffer_init_ex(&to_ctx->buffer, PHP_HTTP_BUFFER_DEFAULT_SIZE, p ? PHP_HTTP_BUFFER_INIT_PERSISTENT : 0)) {
                to_ctx->hexlen = from_ctx->hexlen;
@@ -474,15 +466,14 @@ static php_http_encoding_stream_t *dechunk_copy(php_http_encoding_stream_t *from
                return to;
        }
        pefree(to_ctx, p);
-       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to copy inflate encoding stream: out of memory");
+       php_error_docref(NULL, E_WARNING, "Failed to copy inflate encoding stream: out of memory");
        return NULL;
 }
 
-static STATUS deflate_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **encoded, size_t *encoded_len)
+static ZEND_RESULT_CODE deflate_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **encoded, size_t *encoded_len)
 {
        int status;
        z_streamp ctx = s->ctx;
-       TSRMLS_FETCH_FROM_CTX(s->ts);
        
        /* append input to our buffer */
        php_http_buffer_append(PHP_HTTP_BUFFER(ctx->opaque), data, data_len);
@@ -515,15 +506,14 @@ static STATUS deflate_update(php_http_encoding_stream_t *s, const char *data, si
        
        PTR_SET(*encoded, NULL);
        *encoded_len = 0;
-       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to update deflate stream: %s", zError(status));
+       php_error_docref(NULL, E_WARNING, "Failed to update deflate stream: %s", zError(status));
        return FAILURE;
 }
 
-static STATUS inflate_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **decoded, size_t *decoded_len)
+static ZEND_RESULT_CODE inflate_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **decoded, size_t *decoded_len)
 {
        int status;
        z_streamp ctx = s->ctx;
-       TSRMLS_FETCH_FROM_CTX(s->ts);
        
        /* append input to buffer */
        php_http_buffer_append(PHP_HTTP_BUFFER(ctx->opaque), data, data_len);
@@ -554,18 +544,17 @@ retry_raw_inflate:
                        break;
        }
        
-       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to update inflate stream: %s", zError(status));
+       php_error_docref(NULL, E_WARNING, "Failed to update inflate stream: %s", zError(status));
        return FAILURE;
 }
 
-static STATUS dechunk_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **decoded, size_t *decoded_len)
+static ZEND_RESULT_CODE dechunk_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **decoded, size_t *decoded_len)
 {
        php_http_buffer_t tmp;
        struct dechunk_ctx *ctx = s->ctx;
-       TSRMLS_FETCH_FROM_CTX(s->ts);
 
        if (ctx->zeroed) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Dechunk encoding stream has already reached the end of chunked input");
+               php_error_docref(NULL, E_WARNING, "Dechunk encoding stream has already reached the end of chunked input");
                return FAILURE;
        }
        if ((PHP_HTTP_BUFFER_NOMEM == php_http_buffer_append(&ctx->buffer, data, data_len)) || !php_http_buffer_fix(&ctx->buffer)) {
@@ -686,11 +675,10 @@ static STATUS dechunk_update(php_http_encoding_stream_t *s, const char *data, si
        return SUCCESS;
 }
 
-static STATUS deflate_flush(php_http_encoding_stream_t *s, char **encoded, size_t *encoded_len)
+static ZEND_RESULT_CODE deflate_flush(php_http_encoding_stream_t *s, char **encoded, size_t *encoded_len)
 {
        int status;
        z_streamp ctx = s->ctx;
-       TSRMLS_FETCH_FROM_CTX(s->ts);
        
        *encoded_len = PHP_HTTP_DEFLATE_BUFFER_SIZE;
        *encoded = emalloc(*encoded_len);
@@ -711,11 +699,11 @@ static STATUS deflate_flush(php_http_encoding_stream_t *s, char **encoded, size_
        
        PTR_SET(*encoded, NULL);
        *encoded_len = 0;
-       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to flush deflate stream: %s", zError(status));
+       php_error_docref(NULL, E_WARNING, "Failed to flush deflate stream: %s", zError(status));
        return FAILURE;
 }
 
-static STATUS dechunk_flush(php_http_encoding_stream_t *s, char **decoded, size_t *decoded_len)
+static ZEND_RESULT_CODE dechunk_flush(php_http_encoding_stream_t *s, char **decoded, size_t *decoded_len)
 {
        struct dechunk_ctx *ctx = s->ctx;
 
@@ -735,11 +723,10 @@ static STATUS dechunk_flush(php_http_encoding_stream_t *s, char **decoded, size_
        return SUCCESS;
 }
 
-static STATUS deflate_finish(php_http_encoding_stream_t *s, char **encoded, size_t *encoded_len)
+static ZEND_RESULT_CODE deflate_finish(php_http_encoding_stream_t *s, char **encoded, size_t *encoded_len)
 {
        int status;
        z_streamp ctx = s->ctx;
-       TSRMLS_FETCH_FROM_CTX(s->ts);
        
        *encoded_len = PHP_HTTP_DEFLATE_BUFFER_SIZE;
        *encoded = emalloc(*encoded_len);
@@ -768,15 +755,14 @@ static STATUS deflate_finish(php_http_encoding_stream_t *s, char **encoded, size
        
        PTR_SET(*encoded, NULL);
        *encoded_len = 0;
-       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to finish deflate stream: %s", zError(status));
+       php_error_docref(NULL, E_WARNING, "Failed to finish deflate stream: %s", zError(status));
        return FAILURE;
 }
 
-static STATUS inflate_finish(php_http_encoding_stream_t *s, char **decoded, size_t *decoded_len)
+static ZEND_RESULT_CODE inflate_finish(php_http_encoding_stream_t *s, char **decoded, size_t *decoded_len)
 {
        int status;
        z_streamp ctx = s->ctx;
-       TSRMLS_FETCH_FROM_CTX(s->ts);
        
        if (!PHP_HTTP_BUFFER(ctx->opaque)->used) {
                *decoded = NULL;
@@ -807,7 +793,7 @@ static STATUS inflate_finish(php_http_encoding_stream_t *s, char **decoded, size
        
        PTR_SET(*decoded, NULL);
        *decoded_len = 0;
-       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to finish inflate stream: %s", zError(status));
+       php_error_docref(NULL, E_WARNING, "Failed to finish inflate stream: %s", zError(status));
        return FAILURE;
 }
 
@@ -914,53 +900,47 @@ php_http_encoding_stream_ops_t *php_http_encoding_stream_get_dechunk_ops(void)
 
 static zend_object_handlers php_http_encoding_stream_object_handlers;
 
-zend_object_value php_http_encoding_stream_object_new(zend_class_entry *ce TSRMLS_DC)
+zend_object *php_http_encoding_stream_object_new(zend_class_entry *ce)
 {
-       return php_http_encoding_stream_object_new_ex(ce, NULL, NULL TSRMLS_CC);
+       return &php_http_encoding_stream_object_new_ex(ce, NULL)->zo;
 }
 
-zend_object_value php_http_encoding_stream_object_new_ex(zend_class_entry *ce, php_http_encoding_stream_t *s, php_http_encoding_stream_object_t **ptr TSRMLS_DC)
+php_http_encoding_stream_object_t *php_http_encoding_stream_object_new_ex(zend_class_entry *ce, php_http_encoding_stream_t *s)
 {
        php_http_encoding_stream_object_t *o;
 
-       o = ecalloc(1, sizeof(*o));
-       zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-       object_properties_init((zend_object *) o, ce);
-
-       if (ptr) {
-               *ptr = o;
-       }
+       o = ecalloc(1, sizeof(*o) + (ce->default_properties_count - 1) * sizeof(zval));
+       zend_object_std_init(&o->zo, ce);
+       object_properties_init(&o->zo, ce);
 
        if (s) {
                o->stream = s;
        }
 
-       o->zv.handle = zend_objects_store_put((zend_object *) o, NULL, php_http_encoding_stream_object_free, NULL TSRMLS_CC);
-       o->zv.handlers = &php_http_encoding_stream_object_handlers;
+       o->zo.handlers = &php_http_encoding_stream_object_handlers;
 
-       return o->zv;
+       return o;
 }
 
-zend_object_value php_http_encoding_stream_object_clone(zval *this_ptr TSRMLS_DC)
+zend_object *php_http_encoding_stream_object_clone(zval *object)
 {
-       zend_object_value new_ov;
-       php_http_encoding_stream_object_t *new_obj = NULL, *old_obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       php_http_encoding_stream_object_t *new_obj = NULL, *old_obj = PHP_HTTP_OBJ(NULL, object);
+       php_http_encoding_stream_t *cpy = php_http_encoding_stream_copy(old_obj->stream, NULL);
 
-       new_ov = php_http_encoding_stream_object_new_ex(old_obj->zo.ce, php_http_encoding_stream_copy(old_obj->stream, NULL), &new_obj TSRMLS_CC);
-       zend_objects_clone_members(&new_obj->zo, new_ov, &old_obj->zo, Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC);
+       new_obj = php_http_encoding_stream_object_new_ex(old_obj->zo.ce, cpy);
+       zend_objects_clone_members(&new_obj->zo, &old_obj->zo);
 
-       return new_ov;
+       return &new_obj->zo;
 }
 
-void php_http_encoding_stream_object_free(void *object TSRMLS_DC)
+void php_http_encoding_stream_object_free(zend_object *object)
 {
-       php_http_encoding_stream_object_t *o = (php_http_encoding_stream_object_t *) object;
+       php_http_encoding_stream_object_t *o = PHP_HTTP_OBJ(object, NULL);
 
        if (o->stream) {
                php_http_encoding_stream_free(&o->stream);
        }
-       zend_object_std_dtor((zend_object *) o TSRMLS_CC);
-       efree(o);
+       zend_object_std_dtor(object);
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpEncodingStream___construct, 0, 0, 0)
@@ -968,31 +948,31 @@ ZEND_BEGIN_ARG_INFO_EX(ai_HttpEncodingStream___construct, 0, 0, 0)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpEncodingStream, __construct)
 {
-       long flags = 0;
+       zend_long flags = 0;
        php_http_encoding_stream_object_t *obj;
        php_http_encoding_stream_ops_t *ops;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &flags), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        if (obj->stream) {
                php_http_throw(bad_method_call, "http\\Encoding\\Stream cannot be initialized twice", NULL);
                return;
        }
 
-       if (instanceof_function(obj->zo.ce, php_http_deflate_stream_class_entry TSRMLS_CC)) {
+       if (instanceof_function(obj->zo.ce, php_http_deflate_stream_class_entry)) {
                ops = &php_http_encoding_deflate_ops;
-       } else if (instanceof_function(obj->zo.ce, php_http_inflate_stream_class_entry TSRMLS_CC)) {
+       } else if (instanceof_function(obj->zo.ce, php_http_inflate_stream_class_entry)) {
                ops = &php_http_encoding_inflate_ops;
-       } else if (instanceof_function(obj->zo.ce, php_http_dechunk_stream_class_entry TSRMLS_CC)) {
+       } else if (instanceof_function(obj->zo.ce, php_http_dechunk_stream_class_entry)) {
                ops = &php_http_encoding_dechunk_ops;
        } else {
-               php_http_throw(runtime, "Unknown http\\Encoding\\Stream class '%s'", obj->zo.ce->name);
+               php_http_throw(runtime, "Unknown http\\Encoding\\Stream class '%s'", obj->zo.ce->name->val);
                return;
        }
 
-       php_http_expect(obj->stream = php_http_encoding_stream_init(obj->stream, ops, flags TSRMLS_CC), runtime, return);
+       php_http_expect(obj->stream = php_http_encoding_stream_init(obj->stream, ops, flags), runtime, return);
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpEncodingStream_update, 0, 0, 1)
@@ -1000,18 +980,22 @@ ZEND_BEGIN_ARG_INFO_EX(ai_HttpEncodingStream_update, 0, 0, 1)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpEncodingStream, update)
 {
-       int data_len;
+       size_t data_len;
        char *data_str;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data_str, &data_len)) {
-               php_http_encoding_stream_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &data_str, &data_len)) {
+               php_http_encoding_stream_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                if (obj->stream) {
+                       char *encoded_str = NULL;
                        size_t encoded_len;
-                       char *encoded_str;
 
                        if (SUCCESS == php_http_encoding_stream_update(obj->stream, data_str, data_len, &encoded_str, &encoded_len)) {
-                               RETURN_STRINGL(encoded_str, encoded_len, 0);
+                               if (encoded_str) {
+                                       RETURN_STR(php_http_cs2zs(encoded_str, encoded_len));
+                               } else {
+                                       RETURN_EMPTY_STRING();
+                               }
                        }
                }
        }
@@ -1022,15 +1006,15 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpEncodingStream, flush)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_encoding_stream_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+               php_http_encoding_stream_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                if (obj->stream) {
-                       char *encoded_str;
+                       char *encoded_str = NULL;
                        size_t encoded_len;
 
                        if (SUCCESS == php_http_encoding_stream_flush(obj->stream, &encoded_str, &encoded_len)) {
                                if (encoded_str) {
-                                       RETURN_STRINGL(encoded_str, encoded_len, 0);
+                                       RETURN_STR(php_http_cs2zs(encoded_str, encoded_len));
                                } else {
                                        RETURN_EMPTY_STRING();
                                }
@@ -1044,7 +1028,7 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpEncodingStream, done)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_encoding_stream_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+               php_http_encoding_stream_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                if (obj->stream) {
                        RETURN_BOOL(php_http_encoding_stream_done(obj->stream));
@@ -1057,16 +1041,16 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpEncodingStream, finish)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_encoding_stream_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+               php_http_encoding_stream_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                if (obj->stream) {
-                       char *encoded_str;
+                       char *encoded_str = NULL;
                        size_t encoded_len;
 
                        if (SUCCESS == php_http_encoding_stream_finish(obj->stream, &encoded_str, &encoded_len)) {
                                if (SUCCESS == php_http_encoding_stream_reset(&obj->stream)) {
                                        if (encoded_str) {
-                                               RETURN_STRINGL(encoded_str, encoded_len, 0);
+                                               RETURN_STR(php_http_cs2zs(encoded_str, encoded_len));
                                        } else {
                                                RETURN_EMPTY_STRING();
                                        }
@@ -1094,15 +1078,19 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpDeflateStream, encode)
 {
        char *str;
-       int len;
-       long flags = 0;
+       size_t len;
+       zend_long flags = 0;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &str, &len, &flags)) {
-               char *enc_str;
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &str, &len, &flags)) {
+               char *enc_str = NULL;
                size_t enc_len;
 
-               if (SUCCESS == php_http_encoding_deflate(flags, str, len, &enc_str, &enc_len TSRMLS_CC)) {
-                       RETURN_STRINGL(enc_str, enc_len, 0);
+               if (SUCCESS == php_http_encoding_deflate(flags, str, len, &enc_str, &enc_len)) {
+                       if (enc_str) {
+                               RETURN_STR(php_http_cs2zs(enc_str, enc_len));
+                       } else {
+                               RETURN_EMPTY_STRING();
+                       }
                }
        }
        RETURN_FALSE;
@@ -1119,14 +1107,18 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpInflateStream, decode)
 {
        char *str;
-       int len;
+       size_t len;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &len)) {
-               char *enc_str;
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &str, &len)) {
+               char *enc_str = NULL;
                size_t enc_len;
 
-               if (SUCCESS == php_http_encoding_inflate(str, len, &enc_str, &enc_len TSRMLS_CC)) {
-                       RETURN_STRINGL(enc_str, enc_len, 0);
+               if (SUCCESS == php_http_encoding_inflate(str, len, &enc_str, &enc_len)) {
+                       if (enc_str) {
+                               RETURN_STR(php_http_cs2zs(enc_str, enc_len));
+                       } else {
+                               RETURN_EMPTY_STRING();
+                       }
                }
        }
        RETURN_FALSE;
@@ -1144,20 +1136,24 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpDechunkStream, decode)
 {
        char *str;
-       int len;
+       size_t len;
        zval *zlen = NULL;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z!", &str, &len, &zlen)) {
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!", &str, &len, &zlen)) {
                const char *end_ptr;
-               char *enc_str;
+               char *enc_str = NULL;
                size_t enc_len;
 
-               if ((end_ptr = php_http_encoding_dechunk(str, len, &enc_str, &enc_len TSRMLS_CC))) {
+               if ((end_ptr = php_http_encoding_dechunk(str, len, &enc_str, &enc_len))) {
                        if (zlen) {
                                zval_dtor(zlen);
                                ZVAL_LONG(zlen, str + len - end_ptr);
                        }
-                       RETURN_STRINGL(enc_str, enc_len, 0);
+                       if (enc_str) {
+                               RETURN_STR(php_http_cs2zs(enc_str, enc_len));
+                       } else {
+                               RETURN_EMPTY_STRING();
+                       }
                }
        }
        RETURN_FALSE;
@@ -1178,39 +1174,40 @@ PHP_MINIT_FUNCTION(http_encoding)
        zend_class_entry ce = {0};
 
        INIT_NS_CLASS_ENTRY(ce, "http\\Encoding", "Stream", php_http_encoding_stream_methods);
-       php_http_encoding_stream_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
+       php_http_encoding_stream_class_entry = zend_register_internal_class(&ce);
        php_http_encoding_stream_class_entry->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS;
        php_http_encoding_stream_class_entry->create_object = php_http_encoding_stream_object_new;
        memcpy(&php_http_encoding_stream_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
        php_http_encoding_stream_object_handlers.clone_obj = php_http_encoding_stream_object_clone;
+       php_http_encoding_stream_object_handlers.dtor_obj = php_http_encoding_stream_object_free;
 
-       zend_declare_class_constant_long(php_http_encoding_stream_class_entry, ZEND_STRL("FLUSH_NONE"), PHP_HTTP_ENCODING_STREAM_FLUSH_NONE TSRMLS_CC);
-       zend_declare_class_constant_long(php_http_encoding_stream_class_entry, ZEND_STRL("FLUSH_SYNC"), PHP_HTTP_ENCODING_STREAM_FLUSH_SYNC TSRMLS_CC);
-       zend_declare_class_constant_long(php_http_encoding_stream_class_entry, ZEND_STRL("FLUSH_FULL"), PHP_HTTP_ENCODING_STREAM_FLUSH_FULL TSRMLS_CC);
+       zend_declare_class_constant_long(php_http_encoding_stream_class_entry, ZEND_STRL("FLUSH_NONE"), PHP_HTTP_ENCODING_STREAM_FLUSH_NONE);
+       zend_declare_class_constant_long(php_http_encoding_stream_class_entry, ZEND_STRL("FLUSH_SYNC"), PHP_HTTP_ENCODING_STREAM_FLUSH_SYNC);
+       zend_declare_class_constant_long(php_http_encoding_stream_class_entry, ZEND_STRL("FLUSH_FULL"), PHP_HTTP_ENCODING_STREAM_FLUSH_FULL);
 
        memset(&ce, 0, sizeof(ce));
        INIT_NS_CLASS_ENTRY(ce, "http\\Encoding\\Stream", "Deflate", php_http_deflate_stream_methods);
-       php_http_deflate_stream_class_entry = zend_register_internal_class_ex(&ce, php_http_encoding_stream_class_entry, NULL TSRMLS_CC);
-
-       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("TYPE_GZIP"), PHP_HTTP_DEFLATE_TYPE_GZIP TSRMLS_CC);
-       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("TYPE_ZLIB"), PHP_HTTP_DEFLATE_TYPE_ZLIB TSRMLS_CC);
-       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("TYPE_RAW"), PHP_HTTP_DEFLATE_TYPE_RAW TSRMLS_CC);
-       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("LEVEL_DEF"), PHP_HTTP_DEFLATE_LEVEL_DEF TSRMLS_CC);
-       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("LEVEL_MIN"), PHP_HTTP_DEFLATE_LEVEL_MIN TSRMLS_CC);
-       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("LEVEL_MAX"), PHP_HTTP_DEFLATE_LEVEL_MAX TSRMLS_CC);
-       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("STRATEGY_DEF"), PHP_HTTP_DEFLATE_STRATEGY_DEF TSRMLS_CC);
-       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("STRATEGY_FILT"), PHP_HTTP_DEFLATE_STRATEGY_FILT TSRMLS_CC);
-       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("STRATEGY_HUFF"), PHP_HTTP_DEFLATE_STRATEGY_HUFF TSRMLS_CC);
-       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("STRATEGY_RLE"), PHP_HTTP_DEFLATE_STRATEGY_RLE TSRMLS_CC);
-       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("STRATEGY_FIXED"), PHP_HTTP_DEFLATE_STRATEGY_FIXED TSRMLS_CC);
+       php_http_deflate_stream_class_entry = zend_register_internal_class_ex(&ce, php_http_encoding_stream_class_entry);
+
+       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("TYPE_GZIP"), PHP_HTTP_DEFLATE_TYPE_GZIP);
+       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("TYPE_ZLIB"), PHP_HTTP_DEFLATE_TYPE_ZLIB);
+       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("TYPE_RAW"), PHP_HTTP_DEFLATE_TYPE_RAW);
+       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("LEVEL_DEF"), PHP_HTTP_DEFLATE_LEVEL_DEF);
+       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("LEVEL_MIN"), PHP_HTTP_DEFLATE_LEVEL_MIN);
+       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("LEVEL_MAX"), PHP_HTTP_DEFLATE_LEVEL_MAX);
+       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("STRATEGY_DEF"), PHP_HTTP_DEFLATE_STRATEGY_DEF);
+       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("STRATEGY_FILT"), PHP_HTTP_DEFLATE_STRATEGY_FILT);
+       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("STRATEGY_HUFF"), PHP_HTTP_DEFLATE_STRATEGY_HUFF);
+       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("STRATEGY_RLE"), PHP_HTTP_DEFLATE_STRATEGY_RLE);
+       zend_declare_class_constant_long(php_http_deflate_stream_class_entry, ZEND_STRL("STRATEGY_FIXED"), PHP_HTTP_DEFLATE_STRATEGY_FIXED);
 
        memset(&ce, 0, sizeof(ce));
        INIT_NS_CLASS_ENTRY(ce, "http\\Encoding\\Stream", "Inflate", php_http_inflate_stream_methods);
-       php_http_inflate_stream_class_entry = zend_register_internal_class_ex(&ce, php_http_encoding_stream_class_entry, NULL TSRMLS_CC);
+       php_http_inflate_stream_class_entry = zend_register_internal_class_ex(&ce, php_http_encoding_stream_class_entry);
 
        memset(&ce, 0, sizeof(ce));
        INIT_NS_CLASS_ENTRY(ce, "http\\Encoding\\Stream", "Dechunk", php_http_dechunk_stream_methods);
-       php_http_dechunk_stream_class_entry = zend_register_internal_class_ex(&ce, php_http_encoding_stream_class_entry, NULL TSRMLS_CC);
+       php_http_dechunk_stream_class_entry = zend_register_internal_class_ex(&ce, php_http_encoding_stream_class_entry);
 
        return SUCCESS;
 }
index 59bbd27..ea767dd 100644 (file)
@@ -125,10 +125,10 @@ typedef struct php_http_encoding_stream php_http_encoding_stream_t;
 
 typedef php_http_encoding_stream_t *(*php_http_encoding_stream_init_func_t)(php_http_encoding_stream_t *s);
 typedef php_http_encoding_stream_t *(*php_http_encoding_stream_copy_func_t)(php_http_encoding_stream_t *from, php_http_encoding_stream_t *to);
-typedef STATUS (*php_http_encoding_stream_update_func_t)(php_http_encoding_stream_t *s, const char *in_str, size_t in_len, char **out_str, size_t *out_len);
-typedef STATUS (*php_http_encoding_stream_flush_func_t)(php_http_encoding_stream_t *s, char **out_str, size_t *out_len);
+typedef ZEND_RESULT_CODE (*php_http_encoding_stream_update_func_t)(php_http_encoding_stream_t *s, const char *in_str, size_t in_len, char **out_str, size_t *out_len);
+typedef ZEND_RESULT_CODE (*php_http_encoding_stream_flush_func_t)(php_http_encoding_stream_t *s, char **out_str, size_t *out_len);
 typedef zend_bool (*php_http_encoding_stream_done_func_t)(php_http_encoding_stream_t *s);
-typedef STATUS (*php_http_encoding_stream_finish_func_t)(php_http_encoding_stream_t *s, char **out_str, size_t *out_len);
+typedef ZEND_RESULT_CODE (*php_http_encoding_stream_finish_func_t)(php_http_encoding_stream_t *s, char **out_str, size_t *out_len);
 typedef void (*php_http_encoding_stream_dtor_func_t)(php_http_encoding_stream_t *s);
 
 typedef struct php_http_encoding_stream_ops {
@@ -145,41 +145,37 @@ struct php_http_encoding_stream {
        unsigned flags;
        void *ctx;
        php_http_encoding_stream_ops_t *ops;
-#ifdef ZTS
-       void ***ts;
-#endif
 };
 
 PHP_HTTP_API php_http_encoding_stream_ops_t *php_http_encoding_stream_get_deflate_ops(void);
 PHP_HTTP_API php_http_encoding_stream_ops_t *php_http_encoding_stream_get_inflate_ops(void);
 PHP_HTTP_API php_http_encoding_stream_ops_t *php_http_encoding_stream_get_dechunk_ops(void);
 
-PHP_HTTP_API php_http_encoding_stream_t *php_http_encoding_stream_init(php_http_encoding_stream_t *s, php_http_encoding_stream_ops_t *ops, unsigned flags TSRMLS_DC);
+PHP_HTTP_API php_http_encoding_stream_t *php_http_encoding_stream_init(php_http_encoding_stream_t *s, php_http_encoding_stream_ops_t *ops, unsigned flags);
 PHP_HTTP_API php_http_encoding_stream_t *php_http_encoding_stream_copy(php_http_encoding_stream_t *from, php_http_encoding_stream_t *to);
-PHP_HTTP_API STATUS php_http_encoding_stream_reset(php_http_encoding_stream_t **s);
-PHP_HTTP_API STATUS php_http_encoding_stream_update(php_http_encoding_stream_t *s, const char *in_str, size_t in_len, char **out_str, size_t *out_len);
-PHP_HTTP_API STATUS php_http_encoding_stream_flush(php_http_encoding_stream_t *s, char **out_str, size_t *len);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_encoding_stream_reset(php_http_encoding_stream_t **s);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_encoding_stream_update(php_http_encoding_stream_t *s, const char *in_str, size_t in_len, char **out_str, size_t *out_len);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_encoding_stream_flush(php_http_encoding_stream_t *s, char **out_str, size_t *len);
 PHP_HTTP_API zend_bool php_http_encoding_stream_done(php_http_encoding_stream_t *s);
-PHP_HTTP_API STATUS php_http_encoding_stream_finish(php_http_encoding_stream_t *s, char **out_str, size_t *len);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_encoding_stream_finish(php_http_encoding_stream_t *s, char **out_str, size_t *len);
 PHP_HTTP_API void php_http_encoding_stream_dtor(php_http_encoding_stream_t *s);
 PHP_HTTP_API void php_http_encoding_stream_free(php_http_encoding_stream_t **s);
 
-PHP_HTTP_API const char *php_http_encoding_dechunk(const char *encoded, size_t encoded_len, char **decoded, size_t *decoded_len TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_encoding_deflate(int flags, const char *data, size_t data_len, char **encoded, size_t *encoded_len TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_encoding_inflate(const char *data, size_t data_len, char **decoded, size_t *decoded_len TSRMLS_DC);
+PHP_HTTP_API const char *php_http_encoding_dechunk(const char *encoded, size_t encoded_len, char **decoded, size_t *decoded_len);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_encoding_deflate(int flags, const char *data, size_t data_len, char **encoded, size_t *encoded_len);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_encoding_inflate(const char *data, size_t data_len, char **decoded, size_t *decoded_len);
 
 typedef struct php_http_encoding_stream_object {
-       zend_object zo;
-       zend_object_value zv;
        php_http_encoding_stream_t *stream;
+       zend_object zo;
 } php_http_encoding_stream_object_t;
 
 PHP_HTTP_API zend_class_entry *php_http_encoding_stream_class_entry;
 
-zend_object_value php_http_encoding_stream_object_new(zend_class_entry *ce TSRMLS_DC);
-zend_object_value php_http_encoding_stream_object_new_ex(zend_class_entry *ce, php_http_encoding_stream_t *s, php_http_encoding_stream_object_t **ptr TSRMLS_DC);
-zend_object_value php_http_encoding_stream_object_clone(zval *object TSRMLS_DC);
-void php_http_encoding_stream_object_free(void *object TSRMLS_DC);
+zend_object *php_http_encoding_stream_object_new(zend_class_entry *ce);
+php_http_encoding_stream_object_t *php_http_encoding_stream_object_new_ex(zend_class_entry *ce, php_http_encoding_stream_t *s);
+zend_object *php_http_encoding_stream_object_clone(zval *object);
+void php_http_encoding_stream_object_free(zend_object *object);
 
 PHP_HTTP_API zend_class_entry *php_http_deflate_stream_class_entry;
 PHP_HTTP_API zend_class_entry *php_http_inflate_stream_class_entry;
index 25759a6..e1ff585 100644 (file)
@@ -430,9 +430,9 @@ static void grab_headers(void *data, void *arg TSRMLS_DC)
        php_http_buffer_appends(PHP_HTTP_BUFFER(arg), PHP_HTTP_CRLF);
 }
 
-STATUS php_http_env_get_response_headers(HashTable *headers_ht TSRMLS_DC)
+ZEND_RESULT_CODE php_http_env_get_response_headers(HashTable *headers_ht TSRMLS_DC)
 {
-       STATUS status;
+       ZEND_RESULT_CODE status;
        php_http_buffer_t headers;
 
        php_http_buffer_init(&headers);
@@ -475,15 +475,15 @@ long php_http_env_get_response_code(TSRMLS_D)
        return code ? code : 200;
 }
 
-STATUS php_http_env_set_response_code(long http_code TSRMLS_DC)
+ZEND_RESULT_CODE php_http_env_set_response_code(long http_code TSRMLS_DC)
 {
        return sapi_header_op(SAPI_HEADER_SET_STATUS, (void *) http_code TSRMLS_CC);
 }
 
-STATUS php_http_env_set_response_status_line(long code, php_http_version_t *v TSRMLS_DC)
+ZEND_RESULT_CODE php_http_env_set_response_status_line(long code, php_http_version_t *v TSRMLS_DC)
 {
        sapi_header_line h = {NULL, 0, 0};
-       STATUS ret;
+       ZEND_RESULT_CODE ret;
 
        h.line_len = spprintf(&h.line, 0, "HTTP/%u.%u %ld %s", v->major, v->minor, code, php_http_env_get_response_status_for_code(code));
        ret = sapi_header_op(SAPI_HEADER_REPLACE, (void *) &h TSRMLS_CC);
@@ -492,22 +492,22 @@ STATUS php_http_env_set_response_status_line(long code, php_http_version_t *v TS
        return ret;
 }
 
-STATUS php_http_env_set_response_protocol_version(php_http_version_t *v TSRMLS_DC)
+ZEND_RESULT_CODE php_http_env_set_response_protocol_version(php_http_version_t *v TSRMLS_DC)
 {
        return php_http_env_set_response_status_line(php_http_env_get_response_code(TSRMLS_C), v TSRMLS_CC);
 }
 
-STATUS php_http_env_set_response_header(long http_code, const char *header_str, size_t header_len, zend_bool replace TSRMLS_DC)
+ZEND_RESULT_CODE php_http_env_set_response_header(long http_code, const char *header_str, size_t header_len, zend_bool replace TSRMLS_DC)
 {
        sapi_header_line h = {estrndup(header_str, header_len), header_len, http_code};
-       STATUS ret = sapi_header_op(replace ? SAPI_HEADER_REPLACE : SAPI_HEADER_ADD, (void *) &h TSRMLS_CC);
+       ZEND_RESULT_CODE ret = sapi_header_op(replace ? SAPI_HEADER_REPLACE : SAPI_HEADER_ADD, (void *) &h TSRMLS_CC);
        efree(h.line);
        return ret;
 }
 
-STATUS php_http_env_set_response_header_va(long http_code, zend_bool replace, const char *fmt, va_list argv TSRMLS_DC)
+ZEND_RESULT_CODE php_http_env_set_response_header_va(long http_code, zend_bool replace, const char *fmt, va_list argv TSRMLS_DC)
 {
-       STATUS ret = FAILURE;
+       ZEND_RESULT_CODE ret = FAILURE;
        sapi_header_line h = {NULL, 0, http_code};
 
        h.line_len = vspprintf(&h.line, 0, fmt, argv);
@@ -521,9 +521,9 @@ STATUS php_http_env_set_response_header_va(long http_code, zend_bool replace, co
        return ret;
 }
 
-STATUS php_http_env_set_response_header_format(long http_code, zend_bool replace TSRMLS_DC, const char *fmt, ...)
+ZEND_RESULT_CODE php_http_env_set_response_header_format(long http_code, zend_bool replace TSRMLS_DC, const char *fmt, ...)
 {
-       STATUS ret;
+       ZEND_RESULT_CODE ret;
        va_list args;
 
        va_start(args, fmt);
@@ -533,7 +533,7 @@ STATUS php_http_env_set_response_header_format(long http_code, zend_bool replace
        return ret;
 }
 
-STATUS php_http_env_set_response_header_value(long http_code, const char *name_str, size_t name_len, zval *value, zend_bool replace TSRMLS_DC)
+ZEND_RESULT_CODE php_http_env_set_response_header_value(long http_code, const char *name_str, size_t name_len, zval *value, zend_bool replace TSRMLS_DC)
 {
        if (!value) {
                sapi_header_line h = {(char *) name_str, name_len, http_code};
@@ -562,7 +562,7 @@ STATUS php_http_env_set_response_header_value(long http_code, const char *name_s
                        return php_http_env_set_response_header_value(http_code, name_str, name_len, NULL, replace TSRMLS_CC);
                } else {
                        sapi_header_line h;
-                       STATUS ret;
+                       ZEND_RESULT_CODE ret;
 
                        if (name_len > INT_MAX) {
                                name_len = INT_MAX;
index 7556c3e..8d2d1bb 100644 (file)
@@ -58,14 +58,14 @@ typedef enum php_http_cache_status {
 
 PHP_HTTP_API long php_http_env_get_response_code(TSRMLS_D);
 PHP_HTTP_API const char *php_http_env_get_response_status_for_code(unsigned code);
-PHP_HTTP_API STATUS php_http_env_get_response_headers(HashTable *headers_ht TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_env_get_response_headers(HashTable *headers_ht TSRMLS_DC);
 PHP_HTTP_API char *php_http_env_get_response_header(const char *name_str, size_t name_len TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_env_set_response_code(long http_code TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_env_set_response_protocol_version(php_http_version_t *v TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_env_set_response_header(long http_code, const char *header_str, size_t header_len, zend_bool replace TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_env_set_response_header_value(long http_code, const char *name_str, size_t name_len, zval *value, zend_bool replace TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_env_set_response_header_format(long http_code, zend_bool replace TSRMLS_DC, const char *fmt, ...);
-PHP_HTTP_API STATUS php_http_env_set_response_header_va(long http_code, zend_bool replace, const char *fmt, va_list argv TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_env_set_response_code(long http_code TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_env_set_response_protocol_version(php_http_version_t *v TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_env_set_response_header(long http_code, const char *header_str, size_t header_len, zend_bool replace TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_env_set_response_header_value(long http_code, const char *name_str, size_t name_len, zval *value, zend_bool replace TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_env_set_response_header_format(long http_code, zend_bool replace TSRMLS_DC, const char *fmt, ...);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_env_set_response_header_va(long http_code, zend_bool replace, const char *fmt, va_list argv TSRMLS_DC);
 
 PHP_HTTP_API zval *php_http_env_get_server_var(const char *key_str, size_t key_len, zend_bool check TSRMLS_DC);
 #define php_http_env_got_server_var(v) (NULL != php_http_env_get_server_var((v), strlen(v), 1 TSRMLS_CC))
index 52d561a..3d8c36d 100644 (file)
@@ -263,7 +263,7 @@ static size_t output(void *context, char *buf, size_t len TSRMLS_DC)
 }
 
 #define php_http_env_response_send_done(r) php_http_env_response_send_data((r), NULL, 0)
-static STATUS php_http_env_response_send_data(php_http_env_response_t *r, const char *buf, size_t len)
+static ZEND_RESULT_CODE php_http_env_response_send_data(php_http_env_response_t *r, const char *buf, size_t len)
 {
        size_t chunks_sent, chunk = r->throttle.chunk ? r->throttle.chunk : PHP_HTTP_SENDBUF_SIZE;
        TSRMLS_FETCH_FROM_CTX(r->ts);
@@ -351,9 +351,9 @@ void php_http_env_response_free(php_http_env_response_t **r)
        }
 }
 
-static STATUS php_http_env_response_send_head(php_http_env_response_t *r, php_http_message_t *request)
+static ZEND_RESULT_CODE php_http_env_response_send_head(php_http_env_response_t *r, php_http_message_t *request)
 {
-       STATUS ret = SUCCESS;
+       ZEND_RESULT_CODE ret = SUCCESS;
        zval *zoption, *options = r->options;
        TSRMLS_FETCH_FROM_CTX(r->ts);
 
@@ -608,9 +608,9 @@ static STATUS php_http_env_response_send_head(php_http_env_response_t *r, php_ht
        return ret;
 }
 
-static STATUS php_http_env_response_send_body(php_http_env_response_t *r)
+static ZEND_RESULT_CODE php_http_env_response_send_body(php_http_env_response_t *r)
 {
-       STATUS ret = SUCCESS;
+       ZEND_RESULT_CODE ret = SUCCESS;
        zval *zoption;
        php_http_message_body_t *body;
        TSRMLS_FETCH_FROM_CTX(r->ts);
@@ -696,7 +696,7 @@ static STATUS php_http_env_response_send_body(php_http_env_response_t *r)
        return ret;
 }
 
-STATUS php_http_env_response_send(php_http_env_response_t *r)
+ZEND_RESULT_CODE php_http_env_response_send(php_http_env_response_t *r)
 {
        php_http_message_t *request;
        php_http_message_body_t *body;
@@ -784,21 +784,21 @@ static long php_http_env_response_sapi_get_status(php_http_env_response_t *r)
 
        return php_http_env_get_response_code(TSRMLS_C);
 }
-static STATUS php_http_env_response_sapi_set_status(php_http_env_response_t *r, long http_code)
+static ZEND_RESULT_CODE php_http_env_response_sapi_set_status(php_http_env_response_t *r, long http_code)
 {
        TSRMLS_FETCH_FROM_CTX(r->ts);
 
        return php_http_env_set_response_code(http_code TSRMLS_CC);
 }
-static STATUS php_http_env_response_sapi_set_protocol_version(php_http_env_response_t *r, php_http_version_t *v)
+static ZEND_RESULT_CODE php_http_env_response_sapi_set_protocol_version(php_http_env_response_t *r, php_http_version_t *v)
 {
        TSRMLS_FETCH_FROM_CTX(r->ts);
 
        return php_http_env_set_response_protocol_version(v TSRMLS_CC);
 }
-static STATUS php_http_env_response_sapi_set_header(php_http_env_response_t *r, const char *fmt, ...)
+static ZEND_RESULT_CODE php_http_env_response_sapi_set_header(php_http_env_response_t *r, const char *fmt, ...)
 {
-       STATUS ret;
+       ZEND_RESULT_CODE ret;
        va_list args;
        TSRMLS_FETCH_FROM_CTX(r->ts);
 
@@ -808,9 +808,9 @@ static STATUS php_http_env_response_sapi_set_header(php_http_env_response_t *r,
 
        return ret;
 }
-static STATUS php_http_env_response_sapi_add_header(php_http_env_response_t *r, const char *fmt, ...)
+static ZEND_RESULT_CODE php_http_env_response_sapi_add_header(php_http_env_response_t *r, const char *fmt, ...)
 {
-       STATUS ret;
+       ZEND_RESULT_CODE ret;
        va_list args;
        TSRMLS_FETCH_FROM_CTX(r->ts);
 
@@ -820,13 +820,13 @@ static STATUS php_http_env_response_sapi_add_header(php_http_env_response_t *r,
 
        return ret;
 }
-static STATUS php_http_env_response_sapi_del_header(php_http_env_response_t *r, const char *header_str, size_t header_len)
+static ZEND_RESULT_CODE php_http_env_response_sapi_del_header(php_http_env_response_t *r, const char *header_str, size_t header_len)
 {
        TSRMLS_FETCH_FROM_CTX(r->ts);
 
        return php_http_env_set_response_header_value(0, header_str, header_len, NULL, 1 TSRMLS_CC);
 }
-static STATUS php_http_env_response_sapi_write(php_http_env_response_t *r, const char *data_str, size_t data_len)
+static ZEND_RESULT_CODE php_http_env_response_sapi_write(php_http_env_response_t *r, const char *data_str, size_t data_len)
 {
        TSRMLS_FETCH_FROM_CTX(r->ts);
 
@@ -835,7 +835,7 @@ static STATUS php_http_env_response_sapi_write(php_http_env_response_t *r, const
        }
        return FAILURE;
 }
-static STATUS php_http_env_response_sapi_flush(php_http_env_response_t *r)
+static ZEND_RESULT_CODE php_http_env_response_sapi_flush(php_http_env_response_t *r)
 {
        TSRMLS_FETCH_FROM_CTX(r->ts);
 
@@ -853,7 +853,7 @@ static STATUS php_http_env_response_sapi_flush(php_http_env_response_t *r)
 
        return SUCCESS;
 }
-static STATUS php_http_env_response_sapi_finish(php_http_env_response_t *r)
+static ZEND_RESULT_CODE php_http_env_response_sapi_finish(php_http_env_response_t *r)
 {
        return SUCCESS;
 }
@@ -888,7 +888,7 @@ typedef struct php_http_env_response_stream_ctx {
        unsigned finished:1;
 } php_http_env_response_stream_ctx_t;
 
-static STATUS php_http_env_response_stream_init(php_http_env_response_t *r, void *init_arg)
+static ZEND_RESULT_CODE php_http_env_response_stream_init(php_http_env_response_t *r, void *init_arg)
 {
        php_http_env_response_stream_ctx_t *ctx;
        TSRMLS_FETCH_FROM_CTX(r->ts);
@@ -935,7 +935,7 @@ static void php_http_env_response_stream_header(php_http_env_response_stream_ctx
                }
        }
 }
-static STATUS php_http_env_response_stream_start(php_http_env_response_stream_ctx_t *ctx TSRMLS_DC)
+static ZEND_RESULT_CODE php_http_env_response_stream_start(php_http_env_response_stream_ctx_t *ctx TSRMLS_DC)
 {
        if (ctx->started || ctx->finished) {
                return FAILURE;
@@ -953,7 +953,7 @@ static long php_http_env_response_stream_get_status(php_http_env_response_t *r)
 
        return ctx->status_code;
 }
-static STATUS php_http_env_response_stream_set_status(php_http_env_response_t *r, long http_code)
+static ZEND_RESULT_CODE php_http_env_response_stream_set_status(php_http_env_response_t *r, long http_code)
 {
        php_http_env_response_stream_ctx_t *stream_ctx = r->ctx;
 
@@ -965,7 +965,7 @@ static STATUS php_http_env_response_stream_set_status(php_http_env_response_t *r
 
        return SUCCESS;
 }
-static STATUS php_http_env_response_stream_set_protocol_version(php_http_env_response_t *r, php_http_version_t *v)
+static ZEND_RESULT_CODE php_http_env_response_stream_set_protocol_version(php_http_env_response_t *r, php_http_version_t *v)
 {
        php_http_env_response_stream_ctx_t *stream_ctx = r->ctx;
 
@@ -977,7 +977,7 @@ static STATUS php_http_env_response_stream_set_protocol_version(php_http_env_res
 
        return SUCCESS;
 }
-static STATUS php_http_env_response_stream_set_header_ex(php_http_env_response_t *r, zend_bool replace, const char *fmt, va_list argv)
+static ZEND_RESULT_CODE php_http_env_response_stream_set_header_ex(php_http_env_response_t *r, zend_bool replace, const char *fmt, va_list argv)
 {
        php_http_env_response_stream_ctx_t *stream_ctx = r->ctx;
        char *header_end, *header_str = NULL;
@@ -1014,9 +1014,9 @@ static STATUS php_http_env_response_stream_set_header_ex(php_http_env_response_t
                return SUCCESS;
        }
 }
-static STATUS php_http_env_response_stream_set_header(php_http_env_response_t *r, const char *fmt, ...)
+static ZEND_RESULT_CODE php_http_env_response_stream_set_header(php_http_env_response_t *r, const char *fmt, ...)
 {
-       STATUS ret;
+       ZEND_RESULT_CODE ret;
        va_list argv;
 
        va_start(argv, fmt);
@@ -1025,9 +1025,9 @@ static STATUS php_http_env_response_stream_set_header(php_http_env_response_t *r
 
        return ret;
 }
-static STATUS php_http_env_response_stream_add_header(php_http_env_response_t *r, const char *fmt, ...)
+static ZEND_RESULT_CODE php_http_env_response_stream_add_header(php_http_env_response_t *r, const char *fmt, ...)
 {
-       STATUS ret;
+       ZEND_RESULT_CODE ret;
        va_list argv;
 
        va_start(argv, fmt);
@@ -1036,7 +1036,7 @@ static STATUS php_http_env_response_stream_add_header(php_http_env_response_t *r
 
        return ret;
 }
-static STATUS php_http_env_response_stream_del_header(php_http_env_response_t *r, const char *header_str, size_t header_len)
+static ZEND_RESULT_CODE php_http_env_response_stream_del_header(php_http_env_response_t *r, const char *header_str, size_t header_len)
 {
        php_http_env_response_stream_ctx_t *stream_ctx = r->ctx;
 
@@ -1047,7 +1047,7 @@ static STATUS php_http_env_response_stream_del_header(php_http_env_response_t *r
        zend_hash_del(&stream_ctx->header, header_str, header_len + 1);
        return SUCCESS;
 }
-static STATUS php_http_env_response_stream_write(php_http_env_response_t *r, const char *data_str, size_t data_len)
+static ZEND_RESULT_CODE php_http_env_response_stream_write(php_http_env_response_t *r, const char *data_str, size_t data_len)
 {
        php_http_env_response_stream_ctx_t *stream_ctx = r->ctx;
        TSRMLS_FETCH_FROM_CTX(r->ts);
@@ -1067,7 +1067,7 @@ static STATUS php_http_env_response_stream_write(php_http_env_response_t *r, con
 
        return SUCCESS;
 }
-static STATUS php_http_env_response_stream_flush(php_http_env_response_t *r)
+static ZEND_RESULT_CODE php_http_env_response_stream_flush(php_http_env_response_t *r)
 {
        php_http_env_response_stream_ctx_t *stream_ctx = r->ctx;
        TSRMLS_FETCH_FROM_CTX(r->ts);
@@ -1083,7 +1083,7 @@ static STATUS php_http_env_response_stream_flush(php_http_env_response_t *r)
 
        return php_stream_flush(stream_ctx->stream);
 }
-static STATUS php_http_env_response_stream_finish(php_http_env_response_t *r)
+static ZEND_RESULT_CODE php_http_env_response_stream_finish(php_http_env_response_t *r)
 {
        php_http_env_response_stream_ctx_t *stream_ctx = r->ctx;
        TSRMLS_FETCH_FROM_CTX(r->ts);
index b672930..e6a112f 100644 (file)
 typedef struct php_http_env_response php_http_env_response_t;
 
 typedef struct php_http_env_response_ops {
-       STATUS (*init)(php_http_env_response_t *r, void *arg);
+       ZEND_RESULT_CODE (*init)(php_http_env_response_t *r, void *arg);
        void (*dtor)(php_http_env_response_t *r);
        long (*get_status)(php_http_env_response_t *r);
-       STATUS (*set_status)(php_http_env_response_t *r, long http_code);
-       STATUS (*set_protocol_version)(php_http_env_response_t *r, php_http_version_t *v);
-       STATUS (*set_header)(php_http_env_response_t *r, const char *fmt, ...);
-       STATUS (*add_header)(php_http_env_response_t *r, const char *fmt, ...);
-       STATUS (*del_header)(php_http_env_response_t *r, const char *header_str, size_t header_len);
-       STATUS (*write)(php_http_env_response_t *r, const char *data_str, size_t data_len);
-       STATUS (*flush)(php_http_env_response_t *r);
-       STATUS (*finish)(php_http_env_response_t *r);
+       ZEND_RESULT_CODE (*set_status)(php_http_env_response_t *r, long http_code);
+       ZEND_RESULT_CODE (*set_protocol_version)(php_http_env_response_t *r, php_http_version_t *v);
+       ZEND_RESULT_CODE (*set_header)(php_http_env_response_t *r, const char *fmt, ...);
+       ZEND_RESULT_CODE (*add_header)(php_http_env_response_t *r, const char *fmt, ...);
+       ZEND_RESULT_CODE (*del_header)(php_http_env_response_t *r, const char *header_str, size_t header_len);
+       ZEND_RESULT_CODE (*write)(php_http_env_response_t *r, const char *data_str, size_t data_len);
+       ZEND_RESULT_CODE (*flush)(php_http_env_response_t *r);
+       ZEND_RESULT_CODE (*finish)(php_http_env_response_t *r);
 } php_http_env_response_ops_t;
 
 PHP_HTTP_API php_http_env_response_ops_t *php_http_env_response_get_sapi_ops(void);
@@ -67,7 +67,7 @@ struct php_http_env_response {
 };
 
 PHP_HTTP_API php_http_env_response_t *php_http_env_response_init(php_http_env_response_t *r, zval *options, php_http_env_response_ops_t *ops, void *ops_ctx TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_env_response_send(php_http_env_response_t *r);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_env_response_send(php_http_env_response_t *r);
 PHP_HTTP_API void php_http_env_response_dtor(php_http_env_response_t *r);
 PHP_HTTP_API void php_http_env_response_free(php_http_env_response_t **r);
 
index 3604ad8..1ebddb3 100644 (file)
@@ -20,7 +20,7 @@
 #include <ext/standard/sha1.h>
 #include <ext/standard/md5.h>
 
-php_http_etag_t *php_http_etag_init(const char *mode TSRMLS_DC)
+php_http_etag_t *php_http_etag_init(const char *mode)
 {
        void *ctx;
        php_http_etag_t *e;
@@ -47,7 +47,6 @@ php_http_etag_t *php_http_etag_init(const char *mode TSRMLS_DC)
        e = emalloc(sizeof(*e));
        e->ctx = ctx;
        e->mode = estrdup(mode);
-       TSRMLS_SET_CTX(e->ts);
 
        return e;
 }
index bf6cf49..f208db7 100644 (file)
 typedef struct php_http_etag {
        void *ctx;
        char *mode;
-
-#ifdef ZTS
-       void ***ts;
-#endif
 } php_http_etag_t;
 
-PHP_HTTP_API php_http_etag_t *php_http_etag_init(const char *mode TSRMLS_DC);
+PHP_HTTP_API php_http_etag_t *php_http_etag_init(const char *mode);
 PHP_HTTP_API size_t php_http_etag_update(php_http_etag_t *e, const char *data_ptr, size_t data_len);
 PHP_HTTP_API char *php_http_etag_finish(php_http_etag_t *e);
 
index 25a33e6..bae09f9 100644 (file)
 #endif
 
 #if PHP_HTTP_DBG_EXCEPTIONS
-static void php_http_exception_hook(zval *ex TSRMLS_DC)
+static void php_http_exception_hook(zval *ex)
 {
        if (ex) {
-               zval *m = zend_read_property(Z_OBJCE_P(ex), ex, "message", lenof("message"), 0 TSRMLS_CC);
+               zval *m = zend_read_property(Z_OBJCE_P(ex), ex, "message", lenof("message"), 0);
                fprintf(stderr, "*** Threw exception '%s'\n", Z_STRVAL_P(m));
        } else {
                fprintf(stderr, "*** Threw NULL exception\n");
@@ -46,7 +46,7 @@ PHP_MINIT_FUNCTION(http_exception)
        zend_class_entry *cep, ce = {0};
 
        INIT_NS_CLASS_ENTRY(ce, "http", "Exception", NULL);
-       php_http_exception_interface_class_entry = zend_register_internal_interface(&ce TSRMLS_CC);
+       php_http_exception_interface_class_entry = zend_register_internal_interface(&ce);
        
        /*
         * Would be great to only have a few exceptions and rather more identifying
@@ -55,56 +55,56 @@ PHP_MINIT_FUNCTION(http_exception)
 
        memset(&ce, 0, sizeof(ce));
        INIT_NS_CLASS_ENTRY(ce, "http\\Exception", "RuntimeException", NULL);
-       cep = zend_register_internal_class_ex(&ce, spl_ce_RuntimeException, NULL TSRMLS_CC);
-       zend_class_implements(cep TSRMLS_CC, 1, php_http_exception_interface_class_entry);
+       cep = zend_register_internal_class_ex(&ce, spl_ce_RuntimeException);
+       zend_class_implements(cep, 1, php_http_exception_interface_class_entry);
        php_http_exception_runtime_class_entry = cep;
 
        memset(&ce, 0, sizeof(ce));
        INIT_NS_CLASS_ENTRY(ce, "http\\Exception", "UnexpectedValueException", NULL);
-       cep = zend_register_internal_class_ex(&ce, spl_ce_UnexpectedValueException, NULL TSRMLS_CC);
-       zend_class_implements(cep TSRMLS_CC, 1, php_http_exception_interface_class_entry);
+       cep = zend_register_internal_class_ex(&ce, spl_ce_UnexpectedValueException);
+       zend_class_implements(cep, 1, php_http_exception_interface_class_entry);
        php_http_exception_unexpected_val_class_entry = cep;
 
        memset(&ce, 0, sizeof(ce));
        INIT_NS_CLASS_ENTRY(ce, "http\\Exception", "BadMethodCallException", NULL);
-       cep = zend_register_internal_class_ex(&ce, spl_ce_BadMethodCallException, NULL TSRMLS_CC);
-       zend_class_implements(cep TSRMLS_CC, 1, php_http_exception_interface_class_entry);
+       cep = zend_register_internal_class_ex(&ce, spl_ce_BadMethodCallException);
+       zend_class_implements(cep, 1, php_http_exception_interface_class_entry);
        php_http_exception_bad_method_call_class_entry = cep;
 
        memset(&ce, 0, sizeof(ce));
        INIT_NS_CLASS_ENTRY(ce, "http\\Exception", "InvalidArgumentException", NULL);
-       cep = zend_register_internal_class_ex(&ce, spl_ce_InvalidArgumentException, NULL TSRMLS_CC);
-       zend_class_implements(cep TSRMLS_CC, 1, php_http_exception_interface_class_entry);
+       cep = zend_register_internal_class_ex(&ce, spl_ce_InvalidArgumentException);
+       zend_class_implements(cep, 1, php_http_exception_interface_class_entry);
        php_http_exception_invalid_arg_class_entry = cep;
 
        memset(&ce, 0, sizeof(ce));
        INIT_NS_CLASS_ENTRY(ce, "http\\Exception", "BadHeaderException", NULL);
-       cep = zend_register_internal_class_ex(&ce, spl_ce_DomainException, NULL TSRMLS_CC);
-       zend_class_implements(cep TSRMLS_CC, 1, php_http_exception_interface_class_entry);
+       cep = zend_register_internal_class_ex(&ce, spl_ce_DomainException);
+       zend_class_implements(cep, 1, php_http_exception_interface_class_entry);
        php_http_exception_bad_header_class_entry = cep;
 
        memset(&ce, 0, sizeof(ce));
        INIT_NS_CLASS_ENTRY(ce, "http\\Exception", "BadUrlException", NULL);
-       cep = zend_register_internal_class_ex(&ce, spl_ce_DomainException, NULL TSRMLS_CC);
-       zend_class_implements(cep TSRMLS_CC, 1, php_http_exception_interface_class_entry);
+       cep = zend_register_internal_class_ex(&ce, spl_ce_DomainException);
+       zend_class_implements(cep, 1, php_http_exception_interface_class_entry);
        php_http_exception_bad_url_class_entry = cep;
 
        memset(&ce, 0, sizeof(ce));
        INIT_NS_CLASS_ENTRY(ce, "http\\Exception", "BadMessageException", NULL);
-       cep = zend_register_internal_class_ex(&ce, spl_ce_DomainException, NULL TSRMLS_CC);
-       zend_class_implements(cep TSRMLS_CC, 1, php_http_exception_interface_class_entry);
+       cep = zend_register_internal_class_ex(&ce, spl_ce_DomainException);
+       zend_class_implements(cep, 1, php_http_exception_interface_class_entry);
        php_http_exception_bad_message_class_entry = cep;
 
        memset(&ce, 0, sizeof(ce));
        INIT_NS_CLASS_ENTRY(ce, "http\\Exception", "BadConversionException", NULL);
-       cep = zend_register_internal_class_ex(&ce, spl_ce_DomainException, NULL TSRMLS_CC);
-       zend_class_implements(cep TSRMLS_CC, 1, php_http_exception_interface_class_entry);
+       cep = zend_register_internal_class_ex(&ce, spl_ce_DomainException);
+       zend_class_implements(cep, 1, php_http_exception_interface_class_entry);
        php_http_exception_bad_conversion_class_entry = cep;
 
        memset(&ce, 0, sizeof(ce));
        INIT_NS_CLASS_ENTRY(ce, "http\\Exception", "BadQueryStringException", NULL);
-       cep = zend_register_internal_class_ex(&ce, spl_ce_DomainException, NULL TSRMLS_CC);
-       zend_class_implements(cep TSRMLS_CC, 1, php_http_exception_interface_class_entry);
+       cep = zend_register_internal_class_ex(&ce, spl_ce_DomainException);
+       zend_class_implements(cep, 1, php_http_exception_interface_class_entry);
        php_http_exception_bad_querystring_class_entry = cep;
 
 #if PHP_HTTP_DBG_EXCEPTIONS
index 969a351..eaf7a13 100644 (file)
 
 /* short hand for zend_throw_exception_ex */
 #define php_http_throw(e, fmt, ...) \
-       zend_throw_exception_ex(php_http_exception_ ##e## _class_entry, 0 TSRMLS_CC, fmt, __VA_ARGS__)
+       zend_throw_exception_ex(php_http_exception_ ##e## _class_entry, 0, fmt, __VA_ARGS__)
 
 /* wrap a call with replaced zend_error_handling */
 #define php_http_expect(test, e, fail) \
        do { \
                zend_error_handling __zeh; \
-               zend_replace_error_handling(EH_THROW, php_http_exception_ ##e## _class_entry, &__zeh TSRMLS_CC); \
+               zend_replace_error_handling(EH_THROW, php_http_exception_ ##e## _class_entry, &__zeh); \
                if (!(test)) { \
-                       zend_restore_error_handling(&__zeh TSRMLS_CC); \
+                       zend_restore_error_handling(&__zeh); \
                        fail; \
                } \
-               zend_restore_error_handling(&__zeh TSRMLS_CC); \
+               zend_restore_error_handling(&__zeh); \
        } while(0)
 
 PHP_HTTP_API zend_class_entry *php_http_exception_interface_class_entry;
index b6d967b..084d989 100644 (file)
@@ -18,7 +18,7 @@
 
 PHP_MINIT_FUNCTION(http_filter)
 {
-       php_stream_filter_register_factory("http.*", &php_http_filter_factory TSRMLS_CC);
+       php_stream_filter_register_factory("http.*", &php_http_filter_factory);
        return SUCCESS;
 }
 
@@ -27,8 +27,8 @@ PHP_MINIT_FUNCTION(http_filter)
        php_stream_filter *this, \
        php_stream_bucket_brigade *buckets_in, \
        php_stream_bucket_brigade *buckets_out, \
-       size_t *bytes_consumed, int flags \
-       TSRMLS_DC
+       size_t *bytes_consumed, \
+       int flags
 #define PHP_HTTP_FILTER_OP(filter) \
        http_filter_op_ ##filter
 #define PHP_HTTP_FILTER_OPS(filter) \
@@ -36,7 +36,7 @@ PHP_MINIT_FUNCTION(http_filter)
 #define PHP_HTTP_FILTER_DTOR(filter) \
        http_filter_ ##filter## _dtor
 #define PHP_HTTP_FILTER_DESTRUCTOR(filter) \
-       void PHP_HTTP_FILTER_DTOR(filter)(php_stream_filter *this TSRMLS_DC)
+       void PHP_HTTP_FILTER_DTOR(filter)(php_stream_filter *this)
 #define PHP_HTTP_FILTER_FUNC(filter) \
        http_filter_ ##filter
 #define PHP_HTTP_FILTER_FUNCTION(filter) \
@@ -61,13 +61,13 @@ PHP_MINIT_FUNCTION(http_filter)
                } \
                memcpy(__data, data, length); \
                \
-               __buck = php_stream_bucket_new(stream, __data, length, 1, this->is_persistent TSRMLS_CC); \
+               __buck = php_stream_bucket_new(stream, __data, length, 1, this->is_persistent); \
                if (!__buck) { \
                        pefree(__data, this->is_persistent); \
                        return PSFS_ERR_FATAL; \
                } \
                \
-               php_stream_bucket_append(buckets_out, __buck TSRMLS_CC); \
+               php_stream_bucket_append(buckets_out, __buck); \
        }
 
 typedef struct _http_chunked_decode_filter_buffer_t {
@@ -81,7 +81,7 @@ static PHP_HTTP_FILTER_FUNCTION(chunked_decode)
 {
        int out_avail = 0;
        php_stream_bucket *ptr, *nxt;
-       PHP_HTTP_FILTER_BUFFER(chunked_decode) *buffer = (PHP_HTTP_FILTER_BUFFER(chunked_decode) *) (this->abstract);
+       PHP_HTTP_FILTER_BUFFER(chunked_decode) *buffer = Z_PTR(this->abstract);
        
        if (bytes_consumed) {
                *bytes_consumed = 0;
@@ -98,8 +98,8 @@ static PHP_HTTP_FILTER_FUNCTION(chunked_decode)
                }
 
                nxt = ptr->next;
-               php_stream_bucket_unlink(ptr TSRMLS_CC);
-               php_stream_bucket_delref(ptr TSRMLS_CC);
+               php_stream_bucket_unlink(ptr);
+               php_stream_bucket_delref(ptr);
        }
        
        if (!php_http_buffer_fix(PHP_HTTP_BUFFER(buffer))) {
@@ -185,7 +185,7 @@ static PHP_HTTP_FILTER_FUNCTION(chunked_decode)
                                        php_http_buffer_cut(PHP_HTTP_BUFFER(buffer), 0, eolstr + eollen - PHP_HTTP_BUFFER(buffer)->data);
                                        /* buffer->hexlen is 0 now or contains the size of the next chunk */
                                        if (!buffer->hexlen) {
-                                               php_stream_notify_info(stream->context, PHP_STREAM_NOTIFY_COMPLETED, NULL, 0);
+                                               php_stream_notify_info(PHP_STREAM_CONTEXT(stream), PHP_STREAM_NOTIFY_COMPLETED, NULL, 0);
                                                break;
                                        }
                                        /* continue */
@@ -211,7 +211,7 @@ static PHP_HTTP_FILTER_FUNCTION(chunked_decode)
 
 static PHP_HTTP_FILTER_DESTRUCTOR(chunked_decode)
 {
-       PHP_HTTP_FILTER_BUFFER(chunked_decode) *b = (PHP_HTTP_FILTER_BUFFER(chunked_decode) *) (this->abstract);
+       PHP_HTTP_FILTER_BUFFER(chunked_decode) *b = Z_PTR(this->abstract);
        
        php_http_buffer_dtor(PHP_HTTP_BUFFER(b));
        pefree(b, this->is_persistent);
@@ -239,7 +239,7 @@ static PHP_HTTP_FILTER_FUNCTION(chunked_encode)
 #endif
                
                nxt = ptr->next;
-               php_stream_bucket_unlink(ptr TSRMLS_CC);
+               php_stream_bucket_unlink(ptr);
                php_http_buffer_appendf(&buf, "%lx" PHP_HTTP_CRLF, (long unsigned int) ptr->buflen);
                php_http_buffer_append(&buf, ptr->buf, ptr->buflen);
                php_http_buffer_appends(&buf, PHP_HTTP_CRLF);
@@ -248,7 +248,7 @@ static PHP_HTTP_FILTER_FUNCTION(chunked_encode)
                NEW_BUCKET(buf.data, buf.used);
                /* reset */
                php_http_buffer_reset(&buf);
-               php_stream_bucket_delref(ptr TSRMLS_CC);
+               php_stream_bucket_delref(ptr);
        }
 
        /* free buffer */
@@ -281,7 +281,7 @@ static PHP_HTTP_FILTER_OPS(chunked_encode) = {
 static PHP_HTTP_FILTER_FUNCTION(zlib)
 {
        php_stream_bucket *ptr, *nxt;
-       PHP_HTTP_FILTER_BUFFER(zlib) *buffer = (PHP_HTTP_FILTER_BUFFER(zlib) *) this->abstract;
+       PHP_HTTP_FILTER_BUFFER(zlib) *buffer = Z_PTR(this->abstract);
        
        if (bytes_consumed) {
                *bytes_consumed = 0;
@@ -301,7 +301,7 @@ static PHP_HTTP_FILTER_FUNCTION(zlib)
 #endif
                
                nxt = ptr->next;
-               php_stream_bucket_unlink(ptr TSRMLS_CC);
+               php_stream_bucket_unlink(ptr);
                php_http_encoding_stream_update(buffer, ptr->buf, ptr->buflen, &encoded, &encoded_len);
                
 #if DBG_FILTER
@@ -314,7 +314,7 @@ static PHP_HTTP_FILTER_FUNCTION(zlib)
                        }
                        efree(encoded);
                }
-               php_stream_bucket_delref(ptr TSRMLS_CC);
+               php_stream_bucket_delref(ptr);
        }
 
        /* flush & close */
@@ -358,7 +358,7 @@ static PHP_HTTP_FILTER_FUNCTION(zlib)
 }
 static PHP_HTTP_FILTER_DESTRUCTOR(zlib)
 {
-       PHP_HTTP_FILTER_BUFFER(zlib) *buffer = (PHP_HTTP_FILTER_BUFFER(zlib) *) this->abstract;
+       PHP_HTTP_FILTER_BUFFER(zlib) *buffer = Z_PTR(this->abstract);
        php_http_encoding_stream_free(&buffer);
 }
 
@@ -374,28 +374,22 @@ static PHP_HTTP_FILTER_OPS(inflate) = {
        "http.inflate"
 };
 
-static php_stream_filter *http_filter_create(const char *name, zval *params, int p TSRMLS_DC)
+static php_stream_filter *http_filter_create(const char *name, zval *params, int p)
 {
-       zval **tmp = &params;
+       zval *tmp = params;
        php_stream_filter *f = NULL;
        int flags = p ? PHP_HTTP_ENCODING_STREAM_PERSISTENT : 0;
        
        if (params) {
                switch (Z_TYPE_P(params)) {
-                       case IS_ARRAY:
-                       case IS_OBJECT:
-                               if (SUCCESS != zend_hash_find(HASH_OF(params), "flags", sizeof("flags"), (void *) &tmp)) {
-                                       break;
-                               }
-                               /* no break */
-                       default:
-                       {
-                               zval *num = php_http_ztyp(IS_LONG, *tmp);
-                               
-                               flags |= (Z_LVAL_P(num) & 0x0fffffff);
-                               zval_ptr_dtor(&num);
-
+               case IS_ARRAY:
+               case IS_OBJECT:
+                       if (!(tmp = zend_hash_str_find(HASH_OF(params), ZEND_STRL("flags")))) {
+                               break;
                        }
+                       /* no break */
+               default:
+                       flags |= zval_get_long(tmp) & 0x0fffffff;
                        break;
                }
        }
@@ -418,7 +412,7 @@ static php_stream_filter *http_filter_create(const char *name, zval *params, int
        if (!strcasecmp(name, "http.inflate")) {
                PHP_HTTP_FILTER_BUFFER(zlib) *b = NULL;
                
-               if ((b = php_http_encoding_stream_init(NULL, php_http_encoding_stream_get_inflate_ops(), flags TSRMLS_CC))) {
+               if ((b = php_http_encoding_stream_init(NULL, php_http_encoding_stream_get_inflate_ops(), flags))) {
                        if (!(f = php_stream_filter_alloc(&PHP_HTTP_FILTER_OP(inflate), b, p))) {
                                php_http_encoding_stream_free(&b);
                        }
@@ -428,7 +422,7 @@ static php_stream_filter *http_filter_create(const char *name, zval *params, int
        if (!strcasecmp(name, "http.deflate")) {
                PHP_HTTP_FILTER_BUFFER(zlib) *b = NULL;
                
-               if ((b = php_http_encoding_stream_init(NULL, php_http_encoding_stream_get_deflate_ops(), flags TSRMLS_CC))) {
+               if ((b = php_http_encoding_stream_init(NULL, php_http_encoding_stream_get_deflate_ops(), flags))) {
                        if (!(f = php_stream_filter_alloc(&PHP_HTTP_FILTER_OP(deflate), b, p))) {
                                php_http_encoding_stream_free(&b);
                        }
index 92a2de4..709b85b 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "php_http_api.h"
 
-STATUS php_http_header_parse(const char *header, size_t length, HashTable *headers, php_http_info_callback_t callback_func, void **callback_data TSRMLS_DC)
+ZEND_RESULT_CODE php_http_header_parse(const char *header, size_t length, HashTable *headers, php_http_info_callback_t callback_func, void **callback_data)
 {
        php_http_header_parser_t ctx;
        php_http_buffer_t buf;
@@ -43,16 +43,17 @@ STATUS php_http_header_parse(const char *header, size_t length, HashTable *heade
 
 void php_http_header_to_callback(HashTable *headers, zend_bool crlf, php_http_pass_format_callback_t cb, void *cb_arg TSRMLS_DC)
 {
-       HashPosition pos1, pos2;
-       php_http_array_hashkey_t key = php_http_array_hashkey_init(0);
-       zval **header, **single_header;
-
-       FOREACH_HASH_KEYVAL(pos1, headers, key, header) {
-               if (key.type == HASH_KEY_IS_STRING) {
-                       if (key.len == sizeof("Set-Cookie") && !strcasecmp(key.str, "Set-Cookie") && Z_TYPE_PP(header) == IS_ARRAY) {
-                               FOREACH_VAL(pos2, *header, single_header) {
-                                       if (Z_TYPE_PP(single_header) == IS_ARRAY) {
-                                               php_http_cookie_list_t *cookie = php_http_cookie_list_from_struct(NULL, *single_header TSRMLS_CC);
+       php_http_arrkey_t key;
+       zval *header, *single_header;
+
+       ZEND_HASH_FOREACH_KEY_VAL(headers, key.h, key.key, header)
+       {
+               if (key.key) {
+                       if (zend_string_equals_literal(key.key, "Set-Cookie") && Z_TYPE_P(header) == IS_ARRAY) {
+                               ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(header), single_header)
+                               {
+                                       if (Z_TYPE_P(single_header) == IS_ARRAY) {
+                                               php_http_cookie_list_t *cookie = php_http_cookie_list_from_struct(NULL, single_header);
 
                                                if (cookie) {
                                                        char *buf;
@@ -64,20 +65,22 @@ void php_http_header_to_callback(HashTable *headers, zend_bool crlf, php_http_pa
                                                        efree(buf);
                                                }
                                        } else {
-                                               zval *strval = php_http_header_value_to_string(*single_header TSRMLS_CC);
+                                               zend_string *zs = php_http_header_value_to_string(single_header);
 
-                                               cb(cb_arg, crlf ? "Set-Cookie: %s" PHP_HTTP_CRLF : "Set-Cookie: %s", Z_STRVAL_P(strval));
-                                               zval_ptr_dtor(&strval);
+                                               cb(cb_arg, crlf ? "Set-Cookie: %s" PHP_HTTP_CRLF : "Set-Cookie: %s", zs->val);
+                                               zend_string_release(zs);
                                        }
                                }
-                       } else {
-                               zval *strval = php_http_header_value_to_string(*header TSRMLS_CC);
-
-                               cb(cb_arg, crlf ? "%s: %s" PHP_HTTP_CRLF : "%s: %s", key.str, Z_STRVAL_P(strval));
-                               zval_ptr_dtor(&strval);
+                               ZEND_HASH_FOREACH_END();
                        }
+               } else {
+                       zend_string *zs = php_http_header_value_to_string(header);
+
+                       cb(cb_arg, crlf ? "%s: %s" PHP_HTTP_CRLF : "%s: %s", key.key->val, zs->val);
+                       zend_string_release(zs);
                }
        }
+       ZEND_HASH_FOREACH_END();
 }
 
 void php_http_header_to_string(php_http_buffer_t *str, HashTable *headers TSRMLS_DC)
@@ -85,33 +88,37 @@ void php_http_header_to_string(php_http_buffer_t *str, HashTable *headers TSRMLS
        php_http_header_to_callback(headers, 1, (php_http_pass_format_callback_t) php_http_buffer_appendf, str TSRMLS_CC);
 }
 
-zval *php_http_header_value_to_string(zval *header TSRMLS_DC)
+zend_string *php_http_header_value_array_to_string(zval *header)
 {
-       zval *ret;
-
-       if (Z_TYPE_P(header) == IS_BOOL) {
-               MAKE_STD_ZVAL(ret);
-               ZVAL_STRING(ret, Z_BVAL_P(header) ? "true" : "false", 1);
-       } else if (Z_TYPE_P(header) == IS_ARRAY) {
-               zval **val;
-               HashPosition pos;
-               php_http_buffer_t str;
-
-               php_http_buffer_init(&str);
-               MAKE_STD_ZVAL(ret);
-               FOREACH_VAL(pos,header, val) {
-                       zval *strval = php_http_header_value_to_string(*val TSRMLS_CC);
-
-                       php_http_buffer_appendf(&str, str.used ? ", %s":"%s", Z_STRVAL_P(strval));
-                       zval_ptr_dtor(&strval);
-               }
-               php_http_buffer_fix(&str);
-               ZVAL_STRINGL(ret, str.data, str.used, 0);
-       } else  {
-               ret = php_http_zsep(1, IS_STRING, header);
+       zval *val;
+       php_http_buffer_t str;
+
+       php_http_buffer_init(&str);
+       ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(header), val)
+       {
+               zend_string *zs = php_http_header_value_to_string(val);
+
+               php_http_buffer_appendf(&str, str.used ? ", %s":"%s", zs->val);
+               zend_string_release(zs);
        }
+       ZEND_HASH_FOREACH_END();
+       php_http_buffer_fix(&str);
+
+       return php_http_cs2zs(str.data, str.used);
+}
 
-       return ret;
+zend_string *php_http_header_value_to_string(zval *header)
+{
+       switch (Z_TYPE_P(header)) {
+       case IS_TRUE:
+               return zend_string_init(ZEND_STRL("true"), 0);
+       case IS_FALSE:
+               return zend_string_init(ZEND_STRL("false"), 0);
+       case IS_ARRAY:
+               return php_http_header_value_array_to_string(header);
+       default:
+               return zval_get_string(header);
+       }
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpHeader___construct, 0, 0, 0)
@@ -121,17 +128,17 @@ ZEND_END_ARG_INFO();
 PHP_METHOD(HttpHeader, __construct)
 {
        char *name_str = NULL, *value_str = NULL;
-       int name_len = 0, value_len = 0;
+       size_t name_len = 0, value_len = 0;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!s!", &name_str, &name_len, &value_str, &value_len), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!", &name_str, &name_len, &value_str, &value_len), invalid_arg, return);
 
        if (name_str && name_len) {
                char *pretty_str = estrndup(name_str, name_len);
-               zend_update_property_stringl(php_http_header_class_entry, getThis(), ZEND_STRL("name"), php_http_pretty_key(pretty_str, name_len, 1, 1), name_len TSRMLS_CC);
+               zend_update_property_stringl(php_http_header_class_entry, getThis(), ZEND_STRL("name"), php_http_pretty_key(pretty_str, name_len, 1, 1), name_len);
                efree(pretty_str);
        }
        if (value_str && value_len) {
-               zend_update_property_stringl(php_http_header_class_entry, getThis(), ZEND_STRL("value"), value_str, value_len TSRMLS_CC);
+               zend_update_property_stringl(php_http_header_class_entry, getThis(), ZEND_STRL("value"), value_str, value_len);
        }
 }
 
@@ -141,22 +148,23 @@ PHP_METHOD(HttpHeader, serialize)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
                php_http_buffer_t buf;
-               zval *zname, *zvalue;
+               zend_string *zs;
 
                php_http_buffer_init(&buf);
-               zname = php_http_ztyp(IS_STRING, zend_read_property(php_http_header_class_entry, getThis(), ZEND_STRL("name"), 0 TSRMLS_CC));
-               php_http_buffer_append(&buf, Z_STRVAL_P(zname), Z_STRLEN_P(zname));
-               zval_ptr_dtor(&zname);
-               zvalue = php_http_ztyp(IS_STRING, zend_read_property(php_http_header_class_entry, getThis(), ZEND_STRL("value"), 0 TSRMLS_CC));
-               if (Z_STRLEN_P(zvalue)) {
+               zs = zval_get_string(zend_read_property(php_http_header_class_entry, getThis(), ZEND_STRL("name"), 0));
+               php_http_buffer_appendz(&buf, zs);
+               zend_string_release(zs);
+
+               zs = zval_get_string(zend_read_property(php_http_header_class_entry, getThis(), ZEND_STRL("value"), 0));
+               if (zs->len) {
                        php_http_buffer_appends(&buf, ": ");
-                       php_http_buffer_append(&buf, Z_STRVAL_P(zvalue), Z_STRLEN_P(zvalue));
+                       php_http_buffer_appendz(&buf, zs);
                } else {
                        php_http_buffer_appends(&buf, ":");
                }
-               zval_ptr_dtor(&zvalue);
+               zend_string_release(zs);
 
-               RETURN_PHP_HTTP_BUFFER_VAL(&buf);
+               RETURN_STR(php_http_cs2zs(buf.data, buf.used));
        }
        RETURN_EMPTY_STRING();
 }
@@ -167,34 +175,31 @@ ZEND_END_ARG_INFO();
 PHP_METHOD(HttpHeader, unserialize)
 {
        char *serialized_str;
-       int serialized_len;
+       size_t serialized_len;
 
        if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &serialized_str, &serialized_len)) {
                HashTable ht;
 
                zend_hash_init(&ht, 1, NULL, ZVAL_PTR_DTOR, 0);
-               if (SUCCESS == php_http_header_parse(serialized_str, serialized_len, &ht, NULL, NULL TSRMLS_CC)) {
+               if (SUCCESS == php_http_header_parse(serialized_str, serialized_len, &ht, NULL, NULL)) {
                        if (zend_hash_num_elements(&ht)) {
-                               zval **val, *cpy;
-                               char *str;
-                               uint len;
-                               ulong idx;
+                               zend_string *zs, *key;
+                               zend_ulong idx;
 
                                zend_hash_internal_pointer_reset(&ht);
-                               switch (zend_hash_get_current_key_ex(&ht, &str, &len, &idx, 0, NULL)) {
+                               switch (zend_hash_get_current_key_ex(&ht, &key, &idx, NULL)) {
                                        case HASH_KEY_IS_STRING:
-                                               zend_update_property_stringl(php_http_header_class_entry, getThis(), ZEND_STRL("name"), str, len - 1 TSRMLS_CC);
+                                               zend_update_property_str(php_http_header_class_entry, getThis(), ZEND_STRL("name"), key);
                                                break;
                                        case HASH_KEY_IS_LONG:
-                                               zend_update_property_long(php_http_header_class_entry, getThis(), ZEND_STRL("name"), idx TSRMLS_CC);
+                                               zend_update_property_long(php_http_header_class_entry, getThis(), ZEND_STRL("name"), idx);
                                                break;
                                        default:
                                                break;
                                }
-                               zend_hash_get_current_data(&ht, (void *) &val);
-                               cpy = php_http_zsep(1, IS_STRING, *val);
-                               zend_update_property(php_http_header_class_entry, getThis(), ZEND_STRL("value"), cpy TSRMLS_CC);
-                               zval_ptr_dtor(&cpy);
+                               zs = zval_get_string(zend_hash_get_current_data(&ht));
+                               zend_update_property_str(php_http_header_class_entry, getThis(), ZEND_STRL("value"), zs);
+                               zend_string_release(zs);
                        }
                }
                zend_hash_destroy(&ht);
@@ -209,17 +214,17 @@ ZEND_END_ARG_INFO();
 PHP_METHOD(HttpHeader, match)
 {
        char *val_str;
-       int val_len;
-       long flags = PHP_HTTP_MATCH_LOOSE;
-       zval *zvalue;
+       size_t val_len;
+       zend_long flags = PHP_HTTP_MATCH_LOOSE;
+       zend_string *zs;
 
-       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sl", &val_str, &val_len, &flags)) {
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "|sl", &val_str, &val_len, &flags)) {
                return;
        }
 
-       zvalue = php_http_ztyp(IS_STRING, zend_read_property(php_http_header_class_entry, getThis(), ZEND_STRL("value"), 0 TSRMLS_CC));
-       RETVAL_BOOL(php_http_match(Z_STRVAL_P(zvalue), val_str, flags));
-       zval_ptr_dtor(&zvalue);
+       zs = zval_get_string(zend_read_property(php_http_header_class_entry, getThis(), ZEND_STRL("value"), 0));
+       RETVAL_BOOL(php_http_match(zs->val, val_str, flags));
+       zend_string_release(zs);
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpHeader_negotiate, 0, 0, 1)
@@ -229,11 +234,12 @@ ZEND_END_ARG_INFO();
 PHP_METHOD(HttpHeader, negotiate)
 {
        HashTable *supported, *rs;
-       zval *zname, *zvalue, *rs_array = NULL;
+       zval *rs_array = NULL;
+       zend_string *zs;
        char *sep_str = NULL;
        size_t sep_len = 0;
 
-       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "H|z", &supported, &rs_array)) {
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "H|z", &supported, &rs_array)) {
                return;
        }
        if (rs_array) {
@@ -241,23 +247,23 @@ PHP_METHOD(HttpHeader, negotiate)
                array_init(rs_array);
        }
 
-       zname = php_http_ztyp(IS_STRING, zend_read_property(php_http_header_class_entry, getThis(), ZEND_STRL("name"), 0 TSRMLS_CC));
-       if (!strcasecmp(Z_STRVAL_P(zname), "Accept")) {
+       zs = zval_get_string(zend_read_property(php_http_header_class_entry, getThis(), ZEND_STRL("name"), 0));
+       if (zend_string_equals_literal(zs, "Accept")) {
                sep_str = "/";
                sep_len = 1;
-       } else if (!strcasecmp(Z_STRVAL_P(zname), "Accept-Language")) {
+       } else if (zend_string_equals_literal(zs, "Accept-Language")) {
                sep_str = "-";
                sep_len = 1;
        }
-       zval_ptr_dtor(&zname);
+       zend_string_release(zs);
 
-       zvalue = php_http_ztyp(IS_STRING, zend_read_property(php_http_header_class_entry, getThis(), ZEND_STRL("value"), 0 TSRMLS_CC));
-       if ((rs = php_http_negotiate(Z_STRVAL_P(zvalue), Z_STRLEN_P(zvalue), supported, sep_str, sep_len TSRMLS_CC))) {
+       zs = zval_get_string(zend_read_property(php_http_header_class_entry, getThis(), ZEND_STRL("value"), 0));
+       if ((rs = php_http_negotiate(zs->val, zs->len, supported, sep_str, sep_len))) {
                PHP_HTTP_DO_NEGOTIATE_HANDLE_RESULT(rs, supported, rs_array);
        } else {
                PHP_HTTP_DO_NEGOTIATE_HANDLE_DEFAULT(supported, rs_array);
        }
-       zval_ptr_dtor(&zvalue);
+       zend_string_release(zs);
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpHeader_getParams, 0, 0, 0)
@@ -268,22 +274,20 @@ ZEND_BEGIN_ARG_INFO_EX(ai_HttpHeader_getParams, 0, 0, 0)
 ZEND_END_ARG_INFO();
 PHP_METHOD(HttpHeader, getParams)
 {
-       zval zctor, *zparams_obj, **zargs = NULL;
+       zval zctor, zparams_obj, *zargs = NULL;
        
-       INIT_PZVAL(&zctor);
-       ZVAL_STRINGL(&zctor, "__construct", lenof("__construct"), 0);
+       ZVAL_STRINGL(&zctor, "__construct", lenof("__construct"));
        
-       MAKE_STD_ZVAL(zparams_obj);
-       object_init_ex(zparams_obj, php_http_params_class_entry);
+       object_init_ex(&zparams_obj, php_http_params_class_entry);
        
-       zargs = (zval **) ecalloc(ZEND_NUM_ARGS()+1, sizeof(zval *));
-       zargs[0] = zend_read_property(Z_OBJCE_P(getThis()), getThis(), ZEND_STRL("value"), 0 TSRMLS_CC);
+       zargs = (zval *) ecalloc(ZEND_NUM_ARGS()+1, sizeof(zval));
+       ZVAL_COPY_VALUE(&zargs[0], zend_read_property(php_http_header_class_entry, getThis(), ZEND_STRL("value"), 0));
        if (ZEND_NUM_ARGS()) {
                zend_get_parameters_array(ZEND_NUM_ARGS(), ZEND_NUM_ARGS(), &zargs[1]);
        }
        
-       if (SUCCESS == call_user_function(NULL, &zparams_obj, &zctor, return_value, ZEND_NUM_ARGS()+1, zargs TSRMLS_CC)) {
-               RETVAL_ZVAL(zparams_obj, 0, 1);
+       if (SUCCESS == call_user_function(NULL, &zparams_obj, &zctor, return_value, ZEND_NUM_ARGS()+1, zargs)) {
+               RETVAL_ZVAL(&zparams_obj, 0, 1);
        }
        
        if (zargs) {
@@ -298,47 +302,43 @@ ZEND_END_ARG_INFO();
 PHP_METHOD(HttpHeader, parse)
 {
        char *header_str;
-       int header_len;
+       size_t header_len;
        zend_class_entry *ce = NULL;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|C", &header_str, &header_len, &ce)) {
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "s|C", &header_str, &header_len, &ce)) {
                array_init(return_value);
 
-               if (SUCCESS != php_http_header_parse(header_str, header_len, Z_ARRVAL_P(return_value), NULL, NULL TSRMLS_CC)) {
+               if (SUCCESS != php_http_header_parse(header_str, header_len, Z_ARRVAL_P(return_value), NULL, NULL)) {
                        zval_dtor(return_value);
                        RETURN_FALSE;
                } else {
                        if (ce && instanceof_function(ce, php_http_header_class_entry TSRMLS_CC)) {
-                               HashPosition pos;
-                               php_http_array_hashkey_t key = php_http_array_hashkey_init(0);
-                               zval **val;
+                               php_http_arrkey_t key;
+                               zval *val;
 
-                               FOREACH_KEYVAL(pos, return_value, key, val) {
-                                       zval *zho, *zkey, *zvalue;
+                               ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(return_value), key.h, key.key, val)
+                               {
+                                       zval zkey, zho;
 
-                                       Z_ADDREF_PP(val);
-                                       zvalue = *val;
-
-                                       MAKE_STD_ZVAL(zkey);
-                                       if (key.type == HASH_KEY_IS_LONG) {
-                                               ZVAL_LONG(zkey, key.num);
+                                       if (key.key) {
+                                               ZVAL_STR_COPY(&zkey, key.key);
                                        } else {
-                                               ZVAL_STRINGL(zkey, key.str, key.len - 1, 1);
+                                               ZVAL_LONG(&zkey, key.h);
                                        }
 
-                                       MAKE_STD_ZVAL(zho);
-                                       object_init_ex(zho, ce);
-                                       zend_call_method_with_2_params(&zho, ce, NULL, "__construct", NULL, zkey, zvalue);
+                                       object_init_ex(&zho, ce);
+                                       Z_TRY_ADDREF_P(val);
+                                       zend_call_method_with_2_params(&zho, ce, NULL, "__construct", NULL, &zkey, val);
+                                       zval_ptr_dtor(val);
+                                       zval_ptr_dtor(&zkey);
 
-                                       if (key.type == HASH_KEY_IS_LONG) {
-                                               zend_hash_index_update(Z_ARRVAL_P(return_value), key.num, (void *) &zho, sizeof(zval *), NULL);
+                                       if (key.key) {
+                                               add_assoc_zval_ex(return_value, key.key->val, key.key->len, &zho);
                                        } else {
-                                               zend_hash_update(Z_ARRVAL_P(return_value), key.str, key.len, (void *) &zho, sizeof(zval *), NULL);
+                                               add_index_zval(return_value, key.h, &zho);
                                        }
-
-                                       zval_ptr_dtor(&zvalue);
-                                       zval_ptr_dtor(&zkey);
                                }
+                               ZEND_HASH_FOREACH_END();
                        }
                }
        }
@@ -364,15 +364,15 @@ PHP_MINIT_FUNCTION(http_header)
        zend_class_entry ce = {0};
 
        INIT_NS_CLASS_ENTRY(ce, "http", "Header", php_http_header_methods);
-       php_http_header_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
-       zend_class_implements(php_http_header_class_entry TSRMLS_CC, 1, zend_ce_serializable);
-       zend_declare_class_constant_long(php_http_header_class_entry, ZEND_STRL("MATCH_LOOSE"), PHP_HTTP_MATCH_LOOSE TSRMLS_CC);
-       zend_declare_class_constant_long(php_http_header_class_entry, ZEND_STRL("MATCH_CASE"), PHP_HTTP_MATCH_CASE TSRMLS_CC);
-       zend_declare_class_constant_long(php_http_header_class_entry, ZEND_STRL("MATCH_WORD"), PHP_HTTP_MATCH_WORD TSRMLS_CC);
-       zend_declare_class_constant_long(php_http_header_class_entry, ZEND_STRL("MATCH_FULL"), PHP_HTTP_MATCH_FULL TSRMLS_CC);
-       zend_declare_class_constant_long(php_http_header_class_entry, ZEND_STRL("MATCH_STRICT"), PHP_HTTP_MATCH_STRICT TSRMLS_CC);
-       zend_declare_property_null(php_http_header_class_entry, ZEND_STRL("name"), ZEND_ACC_PUBLIC TSRMLS_CC);
-       zend_declare_property_null(php_http_header_class_entry, ZEND_STRL("value"), ZEND_ACC_PUBLIC TSRMLS_CC);
+       php_http_header_class_entry = zend_register_internal_class(&ce);
+       zend_class_implements(php_http_header_class_entry, 1, zend_ce_serializable);
+       zend_declare_class_constant_long(php_http_header_class_entry, ZEND_STRL("MATCH_LOOSE"), PHP_HTTP_MATCH_LOOSE);
+       zend_declare_class_constant_long(php_http_header_class_entry, ZEND_STRL("MATCH_CASE"), PHP_HTTP_MATCH_CASE);
+       zend_declare_class_constant_long(php_http_header_class_entry, ZEND_STRL("MATCH_WORD"), PHP_HTTP_MATCH_WORD);
+       zend_declare_class_constant_long(php_http_header_class_entry, ZEND_STRL("MATCH_FULL"), PHP_HTTP_MATCH_FULL);
+       zend_declare_class_constant_long(php_http_header_class_entry, ZEND_STRL("MATCH_STRICT"), PHP_HTTP_MATCH_STRICT);
+       zend_declare_property_null(php_http_header_class_entry, ZEND_STRL("name"), ZEND_ACC_PUBLIC);
+       zend_declare_property_null(php_http_header_class_entry, ZEND_STRL("value"), ZEND_ACC_PUBLIC);
 
        return SUCCESS;
 }
index d420e3f..88ebd10 100644 (file)
 
 #include "php_http_info.h"
 
-PHP_HTTP_API STATUS php_http_header_parse(const char *header, size_t length, HashTable *headers, php_http_info_callback_t callback_func, void **callback_data TSRMLS_DC);
+PHP_HTTP_API ZEND_RESULT_CODE php_http_header_parse(const char *header, size_t length, HashTable *headers, php_http_info_callback_t callback_func, void **callback_data);
 
-PHP_HTTP_API void php_http_header_to_callback(HashTable *headers, zend_bool crlf, php_http_pass_format_callback_t cb, void *cb_arg TSRMLS_DC);
-PHP_HTTP_API void php_http_header_to_string(php_http_buffer_t *str, HashTable *headers TSRMLS_DC);
+PHP_HTTP_API void php_http_header_to_callback(HashTable *headers, zend_bool crlf, php_http_pass_format_callback_t cb, void *cb_arg);
+PHP_HTTP_API void php_http_header_to_string(php_http_buffer_t *str, HashTable *headers);
 
-PHP_HTTP_API zval *php_http_header_value_to_string(zval *header TSRMLS_DC);
+PHP_HTTP_API zend_string *php_http_header_value_to_string(zval *header);
+PHP_HTTP_API zend_string *php_http_header_value_array_to_string(zval *header);
 
 PHP_HTTP_API zend_class_entry *php_http_header_class_entry;
 PHP_MINIT_FUNCTION(http_header);
index df0837d..65c0b24 100644 (file)
@@ -26,15 +26,13 @@ static const php_http_header_parser_state_spec_t php_http_header_parser_states[]
                {PHP_HTTP_HEADER_PARSER_STATE_DONE,                     0}
 };
 
-php_http_header_parser_t *php_http_header_parser_init(php_http_header_parser_t *parser TSRMLS_DC)
+php_http_header_parser_t *php_http_header_parser_init(php_http_header_parser_t *parser)
 {
        if (!parser) {
                parser = emalloc(sizeof(*parser));
        }
        memset(parser, 0, sizeof(*parser));
 
-       TSRMLS_SET_CTX(parser->ts);
-
        return parser;
 }
 
@@ -92,10 +90,8 @@ void php_http_header_parser_free(php_http_header_parser_t **parser)
        }
 }
 
-STATUS php_http_header_parser_parse(php_http_header_parser_t *parser, php_http_buffer_t *buffer, unsigned flags, HashTable *headers, php_http_info_callback_t callback_func, void *callback_arg)
+php_http_header_parser_state_t php_http_header_parser_parse(php_http_header_parser_t *parser, php_http_buffer_t *buffer, unsigned flags, HashTable *headers, php_http_info_callback_t callback_func, void *callback_arg)
 {
-       TSRMLS_FETCH_FROM_CTX(parser->ts);
-
        while (buffer->used || !php_http_header_parser_states[php_http_header_parser_state_is(parser)].need_data) {
 #if 0
                const char *state[] = {"START", "KEY", "VALUE", "HEADER_DONE", "DONE"};
@@ -126,10 +122,10 @@ STATUS php_http_header_parser_parse(php_http_header_parser_t *parser, php_http_b
                                        /* end of headers */
                                        php_http_buffer_cut(buffer, 0, eol_len);
                                        php_http_header_parser_state_push(parser, 1, PHP_HTTP_HEADER_PARSER_STATE_DONE);
-                               } else if (php_http_info_parse(&parser->info, php_http_buffer_fix(buffer)->data TSRMLS_CC)) {
+                               } else if (php_http_info_parse(&parser->info, php_http_buffer_fix(buffer)->data)) {
                                        /* new message starting with request/response line */
                                        if (callback_func) {
-                                               callback_func(callback_arg, &headers, &parser->info TSRMLS_CC);
+                                               callback_func(callback_arg, &headers, &parser->info);
                                        }
                                        php_http_info_dtor(&parser->info);
                                        php_http_buffer_cut(buffer, 0, eol_str + eol_len - buffer->data);
@@ -214,19 +210,19 @@ STATUS php_http_header_parser_parse(php_http_header_parser_t *parser, php_http_b
 
                        case PHP_HTTP_HEADER_PARSER_STATE_HEADER_DONE:
                                if (parser->_key.str && parser->_val.str) {
-                                       zval array, **exist;
+                                       zval tmp, *exist;
 
                                        if (!headers && callback_func) {
-                                               callback_func(callback_arg, &headers, NULL TSRMLS_CC);
+                                               callback_func(callback_arg, &headers, NULL);
                                        }
 
-                                       INIT_PZVAL_ARRAY(&array, headers);
                                        php_http_pretty_key(parser->_key.str, parser->_key.len, 1, 1);
-                                       if (SUCCESS == zend_symtable_find(headers, parser->_key.str, parser->_key.len + 1, (void *) &exist)) {
-                                               convert_to_array(*exist);
-                                               add_next_index_stringl(*exist, parser->_val.str, parser->_val.len, 0);
+                                       if ((exist = zend_symtable_str_find(headers, parser->_key.str, parser->_key.len))) {
+                                               convert_to_array(exist);
+                                               add_next_index_str(exist, php_http_cs2zs(parser->_val.str, parser->_val.len));
                                        } else {
-                                               add_assoc_stringl_ex(&array, parser->_key.str, parser->_key.len + 1, parser->_val.str, parser->_val.len, 0);
+                                               ZVAL_STR(&tmp, php_http_cs2zs(parser->_val.str, parser->_val.len));
+                                               zend_symtable_str_update(headers, parser->_key.str, parser->_key.len, &tmp);
                                        }
                                        parser->_val.str = NULL;
                                }
index 4c60f6e..5b4993a 100644 (file)
@@ -38,12 +38,9 @@ typedef struct php_http_header_parser {
                char *str;
                size_t len;
        } _val;
-#ifdef ZTS
-       void ***ts;
-#endif
 } php_http_header_parser_t;
 
-PHP_HTTP_API php_http_header_parser_t *php_http_header_parser_init(php_http_header_parser_t *parser TSRMLS_DC);
+PHP_HTTP_API php_http_header_parser_t *php_http_header_parser_init(php_http_header_parser_t *parser);
 PHP_HTTP_API php_http_header_parser_state_t php_http_header_parser_state_push(php_http_header_parser_t *parser, unsigned argc, ...);
 PHP_HTTP_API php_http_header_parser_state_t php_http_header_parser_state_is(php_http_header_parser_t *parser);
 PHP_HTTP_API php_http_header_parser_state_t php_http_header_parser_state_pop(php_http_header_parser_t *parser);
index 7efd70e..f0fe7ad 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "php_http_api.h"
 
-php_http_info_t *php_http_info_init(php_http_info_t *i TSRMLS_DC)
+php_http_info_t *php_http_info_init(php_http_info_t *i)
 {
        if (!i) {
                i = emalloc(sizeof(*i));
@@ -49,7 +49,7 @@ void php_http_info_free(php_http_info_t **i)
        }
 }
 
-php_http_info_t *php_http_info_parse(php_http_info_t *info, const char *pre_header TSRMLS_DC)
+php_http_info_t *php_http_info_parse(php_http_info_t *info, const char *pre_header)
 {
        const char *end, *http;
        zend_bool free_info = !info;
@@ -72,7 +72,7 @@ php_http_info_t *php_http_info_parse(php_http_info_t *info, const char *pre_head
        info = php_http_info_init(info TSRMLS_CC);
 
        /* and nothing than SPACE or NUL after HTTP/1.x */
-       if (!php_http_version_parse(&info->http.version, http TSRMLS_CC)
+       if (!php_http_version_parse(&info->http.version, http)
        ||      (http[lenof("HTTP/1.1")] && (!PHP_HTTP_IS_CTYPE(space, http[lenof("HTTP/1.1")])))) {
                if (free_info) {
                        php_http_info_free(&info);
@@ -120,7 +120,7 @@ php_http_info_t *php_http_info_parse(php_http_info_t *info, const char *pre_head
                        while (' ' == *url) ++url;
                        while (' ' == *(http-1)) --http;
                        if (http > url) {
-                               PHP_HTTP_INFO(info).request.url = php_http_url_parse(url, http - url, ~0 TSRMLS_CC);
+                               PHP_HTTP_INFO(info).request.url = php_http_url_parse(url, http - url, ~0);
                        } else {
                                PTR_SET(PHP_HTTP_INFO(info).request.method, NULL);
                                return NULL;
index d31b505..579f573 100644 (file)
@@ -54,10 +54,10 @@ typedef struct php_http_info {
        PHP_HTTP_INFO_IMPL(http, type)
 } php_http_info_t;
 
-typedef zend_bool (*php_http_info_callback_t)(void **callback_data, HashTable **headers, php_http_info_t *info TSRMLS_DC);
+typedef zend_bool (*php_http_info_callback_t)(void **callback_data, HashTable **headers, php_http_info_t *info);
 
-PHP_HTTP_API php_http_info_t *php_http_info_init(php_http_info_t *info TSRMLS_DC);
-PHP_HTTP_API php_http_info_t *php_http_info_parse(php_http_info_t *info, const char *pre_header TSRMLS_DC);
+PHP_HTTP_API php_http_info_t *php_http_info_init(php_http_info_t *info);
+PHP_HTTP_API php_http_info_t *php_http_info_parse(php_http_info_t *info, const char *pre_header);
 PHP_HTTP_API void php_http_info_dtor(php_http_info_t *info);
 PHP_HTTP_API void php_http_info_free(php_http_info_t **info);
 
index 8a7e564..b32a822 100644 (file)
@@ -14,7 +14,7 @@
 
 static void message_headers(php_http_message_t *msg, php_http_buffer_t *str);
 
-zend_bool php_http_message_info_callback(php_http_message_t **message, HashTable **headers, php_http_info_t *info TSRMLS_DC)
+zend_bool php_http_message_info_callback(php_http_message_t **message, HashTable **headers, php_http_info_t *info)
 {
        php_http_message_t *old = *message;
 
@@ -34,24 +34,23 @@ zend_bool php_http_message_info_callback(php_http_message_t **message, HashTable
        return old != *message;
 }
 
-php_http_message_t *php_http_message_init(php_http_message_t *message, php_http_message_type_t type, php_http_message_body_t *body TSRMLS_DC)
+php_http_message_t *php_http_message_init(php_http_message_t *message, php_http_message_type_t type, php_http_message_body_t *body)
 {
        if (!message) {
                message = emalloc(sizeof(*message));
        }
        memset(message, 0, sizeof(*message));
-       TSRMLS_SET_CTX(message->ts);
 
        php_http_message_set_type(message, type);
        message->http.version.major = 1;
        message->http.version.minor = 1;
        zend_hash_init(&message->hdrs, 0, NULL, ZVAL_PTR_DTOR, 0);
-       message->body = body ? body : php_http_message_body_init(NULL, NULL TSRMLS_CC);
+       message->body = body ? body : php_http_message_body_init(NULL, NULL);
 
        return message;
 }
 
-php_http_message_t *php_http_message_init_env(php_http_message_t *message, php_http_message_type_t type TSRMLS_DC)
+php_http_message_t *php_http_message_init_env(php_http_message_t *message, php_http_message_type_t type)
 {
        int free_msg = !message;
        zval *sval, tval;
@@ -59,59 +58,44 @@ php_http_message_t *php_http_message_init_env(php_http_message_t *message, php_h
        
        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 = php_http_message_init(NULL, type, NULL TSRMLS_CC);
-                       if (!SG(sapi_headers).http_status_line || !php_http_info_parse((php_http_info_t *) &message->http, SG(sapi_headers).http_status_line TSRMLS_CC)) {
+                       message = php_http_message_init(NULL, type, NULL);
+                       if (!SG(sapi_headers).http_status_line || !php_http_info_parse((php_http_info_t *) &message->http, SG(sapi_headers).http_status_line)) {
                                if (!(message->http.info.response.code = SG(sapi_headers).http_response_code)) {
                                        message->http.info.response.code = 200;
                                }
                                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));
+                       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(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");
+                               } 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));
                                        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));
-                                       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");
-                                       goto error;
-                               } else {
-                                       php_http_message_body_append(message->body, Z_STRVAL(tval), Z_STRLEN(tval));
-                                       zval_dtor(&tval);
-                               }
-                       }
-#endif
                        break;
                        
                default:
@@ -129,7 +113,7 @@ php_http_message_t *php_http_message_init_env(php_http_message_t *message, php_h
        return message;
 }
 
-php_http_message_t *php_http_message_parse(php_http_message_t *msg, const char *str, size_t len, zend_bool greedy TSRMLS_DC)
+php_http_message_t *php_http_message_parse(php_http_message_t *msg, const char *str, size_t len, zend_bool greedy)
 {
        php_http_message_parser_t p;
        php_http_buffer_t buf;
@@ -137,10 +121,10 @@ php_http_message_t *php_http_message_parse(php_http_message_t *msg, const char *
        int free_msg;
 
        php_http_buffer_from_string_ex(&buf, str, len);
-       php_http_message_parser_init(&p TSRMLS_CC);
+       php_http_message_parser_init(&p);
 
        if ((free_msg = !msg)) {
-               msg = php_http_message_init(NULL, 0, NULL TSRMLS_CC);
+               msg = php_http_message_init(NULL, 0, NULL);
        }
 
        if (greedy) {
@@ -159,27 +143,19 @@ php_http_message_t *php_http_message_parse(php_http_message_t *msg, const char *
        return msg;
 }
 
-zval *php_http_message_header(php_http_message_t *msg, const char *key_str, size_t key_len, int join)
+zval *php_http_message_header(php_http_message_t *msg, const char *key_str, size_t key_len)
 {
-       zval *ret = NULL, **header;
+       zval *ret;
        char *key;
        ALLOCA_FLAG(free_key);
 
        key = do_alloca(key_len + 1, free_key);
+
        memcpy(key, key_str, key_len);
        key[key_len] = '\0';
        php_http_pretty_key(key, key_len, 1, 1);
 
-       if (SUCCESS == zend_symtable_find(&msg->hdrs, key, key_len + 1, (void *) &header)) {
-               if (join && Z_TYPE_PP(header) == IS_ARRAY) {
-                       TSRMLS_FETCH_FROM_CTX(msg->ts);
-
-                       ret = php_http_header_value_to_string(*header TSRMLS_CC);
-               } else {
-                       Z_ADDREF_PP(header);
-                       ret = *header;
-               }
-       }
+       ret = zend_symtable_str_find(&msg->hdrs, key, key_len);
 
        free_alloca(key, free_key);
 
@@ -188,9 +164,8 @@ zval *php_http_message_header(php_http_message_t *msg, const char *key_str, size
 
 zend_bool php_http_message_is_multipart(php_http_message_t *msg, char **boundary)
 {
-       zval *ct = php_http_message_header(msg, ZEND_STRL("Content-Type"), 1);
+       zend_string *ct = php_http_message_header_string(msg, ZEND_STRL("Content-Type"));
        zend_bool is_multipart = 0;
-       TSRMLS_FETCH_FROM_CTX(msg->ts);
 
        if (ct) {
                php_http_params_opts_t popts;
@@ -198,47 +173,49 @@ zend_bool php_http_message_is_multipart(php_http_message_t *msg, char **boundary
 
                ZEND_INIT_SYMTABLE(&params);
                php_http_params_opts_default_get(&popts);
-               popts.input.str = Z_STRVAL_P(ct);
-               popts.input.len = Z_STRLEN_P(ct);
+               popts.input.str = ct->val;
+               popts.input.len = ct->len;
 
-               if (php_http_params_parse(&params, &popts TSRMLS_CC)) {
-                       zval **cur, **arg;
-                       char *ct_str;
+               if (php_http_params_parse(&params, &popts)) {
+                       zval *cur, *arg;
+                       zend_string *ct_str;
+                       zend_ulong index;
 
                        zend_hash_internal_pointer_reset(&params);
 
-                       if (SUCCESS == zend_hash_get_current_data(&params, (void *) &cur)
-                       &&      Z_TYPE_PP(cur) == IS_ARRAY
-                       &&      HASH_KEY_IS_STRING == zend_hash_get_current_key(&params, &ct_str, NULL, 0)
+                       if ((cur = zend_hash_get_current_data(&params))
+                       &&      (Z_TYPE_P(cur) == IS_ARRAY)
+                       &&      (HASH_KEY_IS_STRING == zend_hash_get_current_key(&params, &ct_str, &index))
                        ) {
-                               if (php_http_match(ct_str, "multipart", PHP_HTTP_MATCH_WORD)) {
+                               if (php_http_match(ct_str->val, "multipart", PHP_HTTP_MATCH_WORD)) {
                                        is_multipart = 1;
 
                                        /* get boundary */
                                        if (boundary
-                                       &&      SUCCESS == zend_hash_find(Z_ARRVAL_PP(cur), ZEND_STRS("arguments"), (void *) &arg)
-                                       &&      Z_TYPE_PP(arg) == IS_ARRAY
+                                       &&      (arg = zend_hash_str_find(Z_ARRVAL_P(cur), ZEND_STRL("arguments")))
+                                       &&      Z_TYPE_P(arg) == IS_ARRAY
                                        ) {
-                                               zval **val;
-                                               HashPosition pos;
-                                               php_http_array_hashkey_t key = php_http_array_hashkey_init(0);
+                                               zval *val;
+                                               php_http_arrkey_t key;
 
-                                               FOREACH_KEYVAL(pos, *arg, key, val) {
-                                                       if (key.type == HASH_KEY_IS_STRING && !strcasecmp(key.str, "boundary")) {
-                                                               zval *bnd = php_http_ztyp(IS_STRING, *val);
+                                               ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(arg), key.h, key.key, val)
+                                               {
+                                                       if (key.key && key.key->len == lenof("boundary") && !strcasecmp(key.key->val, "boundary")) {
+                                                               zend_string *bnd = zval_get_string(val);
 
-                                                               if (Z_STRLEN_P(bnd)) {
-                                                                       *boundary = estrndup(Z_STRVAL_P(bnd), Z_STRLEN_P(bnd));
+                                                               if (bnd->len) {
+                                                                       *boundary = estrndup(bnd->val, bnd->len);
                                                                }
-                                                               zval_ptr_dtor(&bnd);
+                                                               zend_string_release(bnd);
                                                        }
                                                }
+                                               ZEND_HASH_FOREACH_END();
                                        }
                                }
                        }
                }
                zend_hash_destroy(&params);
-               zval_ptr_dtor(&ct);
+               zend_string_release(ct);
        }
 
        return is_multipart;
@@ -292,48 +269,45 @@ void php_http_message_set_info(php_http_message_t *message, php_http_info_t *inf
 
 void php_http_message_update_headers(php_http_message_t *msg)
 {
-       zval *h;
+       zval h;
        size_t size;
+       zend_string *cl;
 
        if (php_http_message_body_stream(msg->body)->readfilters.head) {
                /* if a read stream filter is attached to the body the caller must also care for the headers */
        } else if ((size = php_http_message_body_size(msg->body))) {
-               MAKE_STD_ZVAL(h);
-               ZVAL_LONG(h, size);
-               zend_hash_update(&msg->hdrs, "Content-Length", sizeof("Content-Length"), &h, sizeof(zval *), NULL);
+               ZVAL_LONG(&h, size);
+               zend_hash_str_update(&msg->hdrs, "Content-Length", lenof("Content-Length"), &h);
 
                if (msg->body->boundary) {
                        char *str;
                        size_t len;
+                       zend_string *ct;
 
-                       if (!(h = php_http_message_header(msg, ZEND_STRL("Content-Type"), 1))) {
+                       if (!(ct = php_http_message_header_string(msg, ZEND_STRL("Content-Type")))) {
                                len = spprintf(&str, 0, "multipart/form-data; boundary=\"%s\"", msg->body->boundary);
-                               MAKE_STD_ZVAL(h);
-                               ZVAL_STRINGL(h, str, len, 0);
-                               zend_hash_update(&msg->hdrs, "Content-Type", sizeof("Content-Type"), &h, sizeof(zval *), NULL);
-                       } else if (!php_http_match(Z_STRVAL_P(h), "boundary=", PHP_HTTP_MATCH_WORD)) {
-                               zval_dtor(h);
-                               Z_STRLEN_P(h) = spprintf(&Z_STRVAL_P(h), 0, "%s; boundary=\"%s\"", Z_STRVAL_P(h), msg->body->boundary);
-                               zend_hash_update(&msg->hdrs, "Content-Type", sizeof("Content-Type"), &h, sizeof(zval *), NULL);
+                               ZVAL_STR(&h, php_http_cs2zs(str, len));
+                               zend_hash_str_update(&msg->hdrs, "Content-Type", lenof("Content-Type"), &h);
+                       } else if (!php_http_match(ct->val, "boundary=", PHP_HTTP_MATCH_WORD)) {
+                               len = spprintf(&str, 0, "%s; boundary=\"%s\"", ct->val, msg->body->boundary);
+                               ZVAL_STR(&h, php_http_cs2zs(str, len));
+                               zend_hash_str_update(&msg->hdrs, "Content-Type", lenof("Content-Type"), &h);
+                               zend_string_release(ct);
                        } else {
-                               zval_ptr_dtor(&h);
+                               zend_string_release(ct);
                        }
                }
-       } else if ((h = php_http_message_header(msg, ZEND_STRL("Content-Length"), 1))) {
-               zval *h_cpy = php_http_ztyp(IS_LONG, h);
-
-               zval_ptr_dtor(&h);
-               if (Z_LVAL_P(h_cpy)) {
-                       zend_hash_del(&msg->hdrs, "Content-Length", sizeof("Content-Length"));
+       } else if ((cl = php_http_message_header_string(msg, ZEND_STRL("Content-Length")))) {
+               if (!zend_string_equals_literal(cl, "0")) {
+                       zend_hash_str_del(&msg->hdrs, ZEND_STRL("Content-Length"));
                }
-               zval_ptr_dtor(&h_cpy);
+               zend_string_release(cl);
        }
 }
 
 static void message_headers(php_http_message_t *msg, php_http_buffer_t *str)
 {
        char *tmp = NULL;
-       TSRMLS_FETCH_FROM_CTX(msg->ts);
 
        switch (msg->type) {
                case PHP_HTTP_REQUEST:
@@ -351,7 +325,7 @@ static void message_headers(php_http_message_t *msg, php_http_buffer_t *str)
        }
 
        php_http_message_update_headers(msg);
-       php_http_header_to_string(str, &msg->hdrs TSRMLS_CC);
+       php_http_header_to_string(str, &msg->hdrs);
 }
 
 void php_http_message_to_callback(php_http_message_t *msg, php_http_pass_callback_t cb, void *cb_arg)
@@ -414,9 +388,7 @@ void php_http_message_serialize(php_http_message_t *message, char **string, size
 
 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;
@@ -438,11 +410,11 @@ php_http_message_t *php_http_message_reverse(php_http_message_t *msg)
        return msg;
 }
 
-php_http_message_t *php_http_message_zip(php_http_message_t *one, php_http_message_t *two)
+php_http_message_t *php_http_message_zip(php_http_message_t *dst, php_http_message_t *src)
 {
-       php_http_message_t *dst = php_http_message_copy(one, NULL), *src = php_http_message_copy(two, NULL), *tmp_dst, *tmp_src, *ret = dst;
+       php_http_message_t *tmp_dst, *tmp_src, *ret = dst;
 
-       while(dst && src) {
+       while (dst && src) {
                tmp_dst = dst->parent;
                tmp_src = src->parent;
                dst->parent = src;
@@ -460,23 +432,22 @@ php_http_message_t *php_http_message_copy_ex(php_http_message_t *from, php_http_
 {
        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;
@@ -486,11 +457,6 @@ php_http_message_t *php_http_message_copy_ex(php_http_message_t *from, php_http_
        return copy;
 }
 
-php_http_message_t *php_http_message_copy(php_http_message_t *from, php_http_message_t *to)
-{
-       return php_http_message_copy_ex(from, to, 1);
-}
-
 void php_http_message_dtor(php_http_message_t *message)
 {
        if (message) {
@@ -525,141 +491,150 @@ void php_http_message_free(php_http_message_t **message)
        }
 }
 
-static zval *php_http_message_object_read_prop(zval *object, zval *member, int type PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC);
-static void php_http_message_object_write_prop(zval *object, zval *member, zval *value PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC);
-static HashTable *php_http_message_object_get_props(zval *object TSRMLS_DC);
+static zval *php_http_message_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *rv);
+static void php_http_message_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot);
+static HashTable *php_http_message_object_get_props(zval *object);
 
 static zend_object_handlers php_http_message_object_handlers;
 static HashTable php_http_message_object_prophandlers;
 
-typedef void (*php_http_message_object_prophandler_func_t)(php_http_message_object_t *o, zval *v TSRMLS_DC);
+typedef void (*php_http_message_object_prophandler_func_t)(php_http_message_object_t *o, zval *v);
 
 typedef struct php_http_message_object_prophandler {
        php_http_message_object_prophandler_func_t read;
        php_http_message_object_prophandler_func_t write;
 } php_http_message_object_prophandler_t;
 
-static STATUS php_http_message_object_add_prophandler(const char *prop_str, size_t prop_len, php_http_message_object_prophandler_func_t read, php_http_message_object_prophandler_func_t write) {
+static ZEND_RESULT_CODE php_http_message_object_add_prophandler(const char *prop_str, size_t prop_len, php_http_message_object_prophandler_func_t read, php_http_message_object_prophandler_func_t write) {
        php_http_message_object_prophandler_t h = { read, write };
-       return zend_hash_add(&php_http_message_object_prophandlers, prop_str, prop_len + 1, (void *) &h, sizeof(h), NULL);
+       if (!zend_hash_str_add_mem(&php_http_message_object_prophandlers, prop_str, prop_len, (void *) &h, sizeof(h))) {
+               return FAILURE;
+       }
+       return SUCCESS;
 }
-static STATUS php_http_message_object_get_prophandler(const char *prop_str, size_t prop_len, php_http_message_object_prophandler_t **handler) {
-       return zend_hash_find(&php_http_message_object_prophandlers, prop_str, prop_len + 1, (void *) handler);
+static php_http_message_object_prophandler_t *php_http_message_object_get_prophandler(zend_string *name_str) {
+       return zend_hash_str_find_ptr(&php_http_message_object_prophandlers, name_str->val, name_str->len);
 }
-static void php_http_message_object_prophandler_get_type(php_http_message_object_t *obj, zval *return_value TSRMLS_DC) {
+static void php_http_message_object_prophandler_get_type(php_http_message_object_t *obj, zval *return_value) {
        RETVAL_LONG(obj->message->type);
 }
-static void php_http_message_object_prophandler_set_type(php_http_message_object_t *obj, zval *value TSRMLS_DC) {
-       zval *cpy = php_http_ztyp(IS_LONG, value);
-       php_http_message_set_type(obj->message, Z_LVAL_P(cpy));
-       zval_ptr_dtor(&cpy);
+static void php_http_message_object_prophandler_set_type(php_http_message_object_t *obj, zval *value) {
+       php_http_message_set_type(obj->message, zval_get_long(value));
 }
-static void php_http_message_object_prophandler_get_request_method(php_http_message_object_t *obj, zval *return_value TSRMLS_DC) {
+static void php_http_message_object_prophandler_get_request_method(php_http_message_object_t *obj, zval *return_value) {
        if (PHP_HTTP_MESSAGE_TYPE(REQUEST, obj->message) && obj->message->http.info.request.method) {
-               RETVAL_STRING(obj->message->http.info.request.method, 1);
+               RETVAL_STRING(obj->message->http.info.request.method);
        } else {
                RETVAL_NULL();
        }
 }
-static void php_http_message_object_prophandler_set_request_method(php_http_message_object_t *obj, zval *value TSRMLS_DC) {
+static void php_http_message_object_prophandler_set_request_method(php_http_message_object_t *obj, zval *value) {
        if (PHP_HTTP_MESSAGE_TYPE(REQUEST, obj->message)) {
-               zval *cpy = php_http_ztyp(IS_STRING, value);
-               PTR_SET(obj->message->http.info.request.method, estrndup(Z_STRVAL_P(cpy), Z_STRLEN_P(cpy)));
-               zval_ptr_dtor(&cpy);
+               zend_string *zs = zval_get_string(value);
+               PTR_SET(obj->message->http.info.request.method, estrndup(zs->val, zs->len));
+               zend_string_release(zs);
        }
 }
-static void php_http_message_object_prophandler_get_request_url(php_http_message_object_t *obj, zval *return_value TSRMLS_DC) {
+static void php_http_message_object_prophandler_get_request_url(php_http_message_object_t *obj, zval *return_value) {
        char *url_str;
        size_t url_len;
 
        if (PHP_HTTP_MESSAGE_TYPE(REQUEST, obj->message) && obj->message->http.info.request.url && php_http_url_to_string(obj->message->http.info.request.url, &url_str, &url_len, 0)) {
-               RETVAL_STRINGL(url_str, url_len, 0);
+               RETVAL_STR(php_http_cs2zs(url_str, url_len));
        } else {
                RETVAL_NULL();
        }
 }
-static void php_http_message_object_prophandler_set_request_url(php_http_message_object_t *obj, zval *value TSRMLS_DC) {
+static void php_http_message_object_prophandler_set_request_url(php_http_message_object_t *obj, zval *value) {
        if (PHP_HTTP_MESSAGE_TYPE(REQUEST, obj->message)) {
-               PTR_SET(obj->message->http.info.request.url, php_http_url_from_zval(value, ~0 TSRMLS_CC));
+               PTR_SET(obj->message->http.info.request.url, php_http_url_from_zval(value, ~0));
        }
 }
-static void php_http_message_object_prophandler_get_response_status(php_http_message_object_t *obj, zval *return_value TSRMLS_DC) {
+static void php_http_message_object_prophandler_get_response_status(php_http_message_object_t *obj, zval *return_value) {
        if (PHP_HTTP_MESSAGE_TYPE(RESPONSE, obj->message) && obj->message->http.info.response.status) {
-               RETVAL_STRING(obj->message->http.info.response.status, 1);
+               RETVAL_STRING(obj->message->http.info.response.status);
        } else {
                RETVAL_NULL();
        }
 }
-static void php_http_message_object_prophandler_set_response_status(php_http_message_object_t *obj, zval *value TSRMLS_DC) {
+static void php_http_message_object_prophandler_set_response_status(php_http_message_object_t *obj, zval *value) {
        if (PHP_HTTP_MESSAGE_TYPE(RESPONSE, obj->message)) {
-               zval *cpy = php_http_ztyp(IS_STRING, value);
-               PTR_SET(obj->message->http.info.response.status, estrndup(Z_STRVAL_P(cpy), Z_STRLEN_P(cpy)));
-               zval_ptr_dtor(&cpy);
+               zend_string *zs = zval_get_string(value);
+               PTR_SET(obj->message->http.info.response.status, estrndup(zs->val, zs->len));
+               zend_string_release(zs);
        }
 }
-static void php_http_message_object_prophandler_get_response_code(php_http_message_object_t *obj, zval *return_value TSRMLS_DC) {
+static void php_http_message_object_prophandler_get_response_code(php_http_message_object_t *obj, zval *return_value) {
        if (PHP_HTTP_MESSAGE_TYPE(RESPONSE, obj->message)) {
                RETVAL_LONG(obj->message->http.info.response.code);
        } else {
                RETVAL_NULL();
        }
 }
-static void php_http_message_object_prophandler_set_response_code(php_http_message_object_t *obj, zval *value TSRMLS_DC) {
+static void php_http_message_object_prophandler_set_response_code(php_http_message_object_t *obj, zval *value) {
        if (PHP_HTTP_MESSAGE_TYPE(RESPONSE, obj->message)) {
-               zval *cpy = php_http_ztyp(IS_LONG, value);
-               obj->message->http.info.response.code = Z_LVAL_P(cpy);
+               obj->message->http.info.response.code = zval_get_long(value);
                PTR_SET(obj->message->http.info.response.status, estrdup(php_http_env_get_response_status_for_code(obj->message->http.info.response.code)));
-               zval_ptr_dtor(&cpy);
        }
 }
-static void php_http_message_object_prophandler_get_http_version(php_http_message_object_t *obj, zval *return_value TSRMLS_DC) {
+static void php_http_message_object_prophandler_get_http_version(php_http_message_object_t *obj, zval *return_value) {
        char *version_str;
        size_t version_len;
 
-       php_http_version_to_string(&obj->message->http.version, &version_str, &version_len, NULL, NULL TSRMLS_CC);
-       RETVAL_STRINGL(version_str, version_len, 0);
+       php_http_version_to_string(&obj->message->http.version, &version_str, &version_len, NULL, NULL);
+       RETVAL_STR(php_http_cs2zs(version_str, version_len));
 }
-static void php_http_message_object_prophandler_set_http_version(php_http_message_object_t *obj, zval *value TSRMLS_DC) {
-       zval *cpy = php_http_ztyp(IS_STRING, value);
-       php_http_version_parse(&obj->message->http.version, Z_STRVAL_P(cpy) TSRMLS_CC);
-       zval_ptr_dtor(&cpy);
+static void php_http_message_object_prophandler_set_http_version(php_http_message_object_t *obj, zval *value) {
+       zend_string *zs = zval_get_string(value);
+       php_http_version_parse(&obj->message->http.version, zs->val);
+       zend_string_release(zs);
 }
-static void php_http_message_object_prophandler_get_headers(php_http_message_object_t *obj, zval *return_value TSRMLS_DC) {
+static void php_http_message_object_prophandler_get_headers(php_http_message_object_t *obj, zval *return_value ) {
        array_init(return_value);
-       zend_hash_copy(Z_ARRVAL_P(return_value), &obj->message->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
+       array_copy(&obj->message->hdrs, Z_ARRVAL_P(return_value));
 }
-static void php_http_message_object_prophandler_set_headers(php_http_message_object_t *obj, zval *value TSRMLS_DC) {
-       zval *cpy = php_http_ztyp(IS_ARRAY, value);
+static void php_http_message_object_prophandler_set_headers(php_http_message_object_t *obj, zval *value) {
+       HashTable *headers;
+       zval *orig_value = value;
+
+       if (Z_TYPE_P(value) != IS_ARRAY && Z_TYPE_P(value) != IS_OBJECT) {
+               convert_to_array_ex(value);
+       } else {
+               headers = HASH_OF(value);
+       }
 
        zend_hash_clean(&obj->message->hdrs);
-       zend_hash_copy(&obj->message->hdrs, Z_ARRVAL_P(cpy), (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
-       zval_ptr_dtor(&cpy);
+       array_copy(headers, &obj->message->hdrs);
+
+       if (orig_value != value) {
+               zval_ptr_dtor(value);
+       }
 }
-static void php_http_message_object_prophandler_get_body(php_http_message_object_t *obj, zval *return_value TSRMLS_DC) {
+static void php_http_message_object_prophandler_get_body(php_http_message_object_t *obj, zval *return_value) {
        if (obj->body) {
-               RETVAL_OBJVAL(obj->body->zv, 1);
+               RETVAL_OBJECT(&obj->body->zo, 1);
        } else {
                RETVAL_NULL();
        }
 }
-static void php_http_message_object_prophandler_set_body(php_http_message_object_t *obj, zval *value TSRMLS_DC) {
-       php_http_message_object_set_body(obj, value TSRMLS_CC);
+static void php_http_message_object_prophandler_set_body(php_http_message_object_t *obj, zval *value) {
+       php_http_message_object_set_body(obj, value);
 }
-static void php_http_message_object_prophandler_get_parent_message(php_http_message_object_t *obj, zval *return_value TSRMLS_DC) {
+static void php_http_message_object_prophandler_get_parent_message(php_http_message_object_t *obj, zval *return_value) {
        if (obj->message->parent) {
-               RETVAL_OBJVAL(obj->parent->zv, 1);
+               RETVAL_OBJECT(&obj->parent->zo, 1);
        } else {
                RETVAL_NULL();
        }
 }
-static void php_http_message_object_prophandler_set_parent_message(php_http_message_object_t *obj, zval *value TSRMLS_DC) {
-       if (Z_TYPE_P(value) == IS_OBJECT && instanceof_function(Z_OBJCE_P(value), php_http_message_class_entry TSRMLS_CC)) {
-               php_http_message_object_t *parent_obj = zend_object_store_get_object(value TSRMLS_CC);
+static void php_http_message_object_prophandler_set_parent_message(php_http_message_object_t *obj, zval *value) {
+       if (Z_TYPE_P(value) == IS_OBJECT && instanceof_function(Z_OBJCE_P(value), php_http_message_class_entry)) {
+               php_http_message_object_t *parent_obj = PHP_HTTP_OBJ(NULL, value);
 
                if (obj->message->parent) {
-                       zend_objects_store_del_ref_by_handle(obj->parent->zv.handle TSRMLS_CC);
+                       zend_objects_store_del(&obj->parent->zo);
                }
-               Z_OBJ_ADDREF_P(value);
+               Z_ADDREF_P(value);
                obj->parent = parent_obj;
                obj->message->parent = parent_obj->message;
        }
@@ -668,20 +643,20 @@ static void php_http_message_object_prophandler_set_parent_message(php_http_mess
 #define PHP_HTTP_MESSAGE_OBJECT_INIT(obj) \
        do { \
                if (!obj->message) { \
-                       obj->message = php_http_message_init(NULL, 0, NULL TSRMLS_CC); \
+                       obj->message = php_http_message_init(NULL, 0, NULL); \
                } \
        } while(0)
 
 
-void php_http_message_object_reverse(zval *this_ptr, zval *return_value TSRMLS_DC)
+void php_http_message_object_reverse(zval *zmsg, zval *return_value)
 {
-       int i = 0;
-       php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       size_t i;
+       php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, zmsg);
 
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
        /* count */
-       php_http_message_count(i, obj->message);
+       i = php_http_message_count(obj->message);
 
        if (i > 1) {
                php_http_message_object_t **objects;
@@ -707,24 +682,20 @@ void php_http_message_object_reverse(zval *this_ptr, zval *return_value TSRMLS_D
                objects[0]->parent = NULL;
 
                /* add ref, because we previously have not been a parent message */
-               Z_OBJ_ADDREF_P(getThis());
-               RETVAL_OBJVAL(objects[last]->zv, 0);
+               Z_ADDREF_P(zmsg);
+               RETVAL_OBJ(&objects[last]->zo);
 
                efree(objects);
        } else {
-               RETURN_ZVAL(getThis(), 1, 0);
+               RETURN_ZVAL_FAST(zmsg);
        }
 }
 
-void php_http_message_object_prepend(zval *this_ptr, zval *prepend, zend_bool top TSRMLS_DC)
+void php_http_message_object_prepend(zval *this_ptr, zval *prepend, zend_bool top)
 {
-       zval m;
        php_http_message_t *save_parent_msg = NULL;
-       php_http_message_object_t *save_parent_obj = NULL, *obj = zend_object_store_get_object(this_ptr TSRMLS_CC);
-       php_http_message_object_t *prepend_obj = zend_object_store_get_object(prepend TSRMLS_CC);
-
-       INIT_PZVAL(&m);
-       m.type = IS_OBJECT;
+       php_http_message_object_t *save_parent_obj = NULL, *obj = PHP_HTTP_OBJ(NULL, this_ptr);
+       php_http_message_object_t *prepend_obj = PHP_HTTP_OBJ(NULL, prepend);
 
        if (!top) {
                save_parent_obj = obj->parent;
@@ -741,7 +712,7 @@ void php_http_message_object_prepend(zval *this_ptr, zval *prepend, zend_bool to
        obj->message->parent = prepend_obj->message;
 
        /* add ref */
-       zend_objects_store_add_ref(prepend TSRMLS_CC);
+       Z_ADDREF_P(prepend);
 
        if (!top) {
                prepend_obj->parent = save_parent_obj;
@@ -749,17 +720,16 @@ void php_http_message_object_prepend(zval *this_ptr, zval *prepend, zend_bool to
        }
 }
 
-STATUS php_http_message_object_set_body(php_http_message_object_t *msg_obj, zval *zbody TSRMLS_DC)
+ZEND_RESULT_CODE php_http_message_object_set_body(php_http_message_object_t *msg_obj, zval *zbody)
 {
-       zval *tmp = NULL;
        php_stream *s;
-       zend_object_value ov;
+       zend_string *body_str;
        php_http_message_body_t *body;
        php_http_message_body_object_t *body_obj;
 
        switch (Z_TYPE_P(zbody)) {
                case IS_RESOURCE:
-                       php_stream_from_zval_no_verify(s, &zbody);
+                       php_stream_from_zval_no_verify(s, zbody);
                        if (!s) {
                                php_http_throw(unexpected_val, "The stream is not a valid resource", NULL);
                                return FAILURE;
@@ -767,112 +737,97 @@ STATUS php_http_message_object_set_body(php_http_message_object_t *msg_obj, zval
 
                        is_resource:
 
-                       body = php_http_message_body_init(NULL, s TSRMLS_CC);
-                       if (SUCCESS != php_http_new(&ov, php_http_message_body_class_entry, (php_http_new_t) php_http_message_body_object_new_ex, NULL, body, NULL TSRMLS_CC)) {
+                       body = php_http_message_body_init(NULL, s);
+                       if (!(body_obj = php_http_message_body_object_new_ex(php_http_message_body_class_entry, body))) {
                                php_http_message_body_free(&body);
                                return FAILURE;
                        }
-                       MAKE_STD_ZVAL(tmp);
-                       ZVAL_OBJVAL(tmp, ov, 0);
-                       zbody = tmp;
                        break;
 
                case IS_OBJECT:
-                       if (instanceof_function(Z_OBJCE_P(zbody), php_http_message_body_class_entry TSRMLS_CC)) {
-                               Z_OBJ_ADDREF_P(zbody);
+                       if (instanceof_function(Z_OBJCE_P(zbody), php_http_message_body_class_entry)) {
+                               Z_ADDREF_P(zbody);
+                               body_obj = PHP_HTTP_OBJ(NULL, zbody);
                                break;
                        }
                        /* no break */
 
                default:
-                       tmp = php_http_ztyp(IS_STRING, zbody);
+                       body_str = zval_get_string(zbody);
                        s = php_stream_temp_new();
-                       php_stream_write(s, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
-                       zval_ptr_dtor(&tmp);
-                       tmp = NULL;
+                       php_stream_write(s, body_str->val, body_str->len);
+                       zend_string_release(body_str);
                        goto is_resource;
 
        }
 
-       body_obj = zend_object_store_get_object(zbody TSRMLS_CC);
        if (!body_obj->body) {
-               body_obj->body = php_http_message_body_init(NULL, NULL TSRMLS_CC);
+               body_obj->body = php_http_message_body_init(NULL, NULL);
        }
        if (msg_obj->body) {
-               zend_objects_store_del_ref_by_handle(msg_obj->body->zv.handle TSRMLS_CC);
+               zend_objects_store_del(&msg_obj->body->zo);
        }
        if (msg_obj->message) {
                php_http_message_body_free(&msg_obj->message->body);
-               msg_obj->message->body = php_http_message_body_init(&body_obj->body, NULL TSRMLS_CC);
+               msg_obj->message->body = php_http_message_body_init(&body_obj->body, NULL);
        } else {
-               msg_obj->message = php_http_message_init(NULL, 0, php_http_message_body_init(&body_obj->body, NULL TSRMLS_CC) TSRMLS_CC);
+               msg_obj->message = php_http_message_init(NULL, 0, php_http_message_body_init(&body_obj->body, NULL));
        }
        msg_obj->body = body_obj;
 
-       if (tmp) {
-               FREE_ZVAL(tmp);
-       }
        return SUCCESS;
 }
 
-STATUS php_http_message_object_init_body_object(php_http_message_object_t *obj)
+ZEND_RESULT_CODE php_http_message_object_init_body_object(php_http_message_object_t *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);
+       return php_http_new((void *) &obj->body, php_http_message_body_class_entry, (php_http_new_t) php_http_message_body_object_new_ex, NULL, obj->message->body);
 }
 
-zend_object_value php_http_message_object_new(zend_class_entry *ce TSRMLS_DC)
+zend_object *php_http_message_object_new(zend_class_entry *ce)
 {
-       return php_http_message_object_new_ex(ce, NULL, NULL TSRMLS_CC);
+       return &php_http_message_object_new_ex(ce, NULL)->zo;
 }
 
-zend_object_value php_http_message_object_new_ex(zend_class_entry *ce, php_http_message_t *msg, php_http_message_object_t **ptr TSRMLS_DC)
+php_http_message_object_t *php_http_message_object_new_ex(zend_class_entry *ce, php_http_message_t *msg)
 {
        php_http_message_object_t *o;
 
-       o = ecalloc(1, sizeof(php_http_message_object_t));
-       zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-       object_properties_init((zend_object *) o, ce);
-
-       if (ptr) {
-               *ptr = o;
-       }
+       o = ecalloc(1, sizeof(php_http_message_object_t) + (ce->default_properties_count - 1) * sizeof(zval));
+       zend_object_std_init(&o->zo, ce);
+       object_properties_init(&o->zo, ce);
 
        if (msg) {
                o->message = msg;
                if (msg->parent) {
-                       php_http_message_object_new_ex(ce, msg->parent, &o->parent TSRMLS_CC);
+                       o->parent = php_http_message_object_new_ex(ce, msg->parent);
                }
-               php_http_message_body_object_new_ex(php_http_message_body_class_entry, php_http_message_body_init(&msg->body, NULL TSRMLS_CC), &o->body TSRMLS_CC);
+               o->body = php_http_message_body_object_new_ex(php_http_message_body_class_entry, php_http_message_body_init(&msg->body, NULL));
        }
 
-       o->zv.handle = zend_objects_store_put((zend_object *) o, NULL, php_http_message_object_free, NULL TSRMLS_CC);
-       o->zv.handlers = &php_http_message_object_handlers;
+       o->zo.handlers = &php_http_message_object_handlers;
 
-       return o->zv;
+       return o;
 }
 
-zend_object_value php_http_message_object_clone(zval *this_ptr TSRMLS_DC)
+zend_object *php_http_message_object_clone(zval *this_ptr TSRMLS_DC)
 {
-       zend_object_value new_ov;
        php_http_message_object_t *new_obj = NULL;
-       php_http_message_object_t *old_obj = zend_object_store_get_object(this_ptr TSRMLS_CC);
+       php_http_message_object_t *old_obj = PHP_HTTP_OBJ(NULL, this_ptr);
 
-       new_ov = php_http_message_object_new_ex(old_obj->zo.ce, php_http_message_copy(old_obj->message, NULL), &new_obj TSRMLS_CC);
-       zend_objects_clone_members(&new_obj->zo, new_ov, &old_obj->zo, Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC);
+       new_obj = php_http_message_object_new_ex(old_obj->zo.ce, php_http_message_copy(old_obj->message, NULL));
+       zend_objects_clone_members(&new_obj->zo, &old_obj->zo);
 
-       return new_ov;
+       return &new_obj->zo;
 }
 
-void php_http_message_object_free(void *object TSRMLS_DC)
+void php_http_message_object_free(zend_object *object)
 {
-       php_http_message_object_t *o = (php_http_message_object_t *) object;
+       php_http_message_object_t *o = PHP_HTTP_OBJ(object, NULL);
 
-       if (o->iterator) {
+       if (!Z_ISUNDEF(o->iterator)) {
                zval_ptr_dtor(&o->iterator);
-               o->iterator = NULL;
+               ZVAL_UNDEF(&o->iterator);
        }
        if (o->message) {
                /* do NOT free recursivly */
@@ -881,146 +836,131 @@ void php_http_message_object_free(void *object TSRMLS_DC)
                o->message = NULL;
        }
        if (o->parent) {
-               zend_objects_store_del_ref_by_handle(o->parent->zv.handle TSRMLS_CC);
+               zend_objects_store_del(&o->parent->zo);
                o->parent = NULL;
        }
        if (o->body) {
-               zend_objects_store_del_ref_by_handle(o->body->zv.handle TSRMLS_CC);
+               zend_objects_store_del(&o->body->zo);
                o->body = NULL;
        }
-       zend_object_std_dtor((zend_object *) o TSRMLS_CC);
-       efree(o);
+       zend_object_std_dtor(object);
 }
 
-static zval *php_http_message_object_read_prop(zval *object, zval *member, int type PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC)
+static zval *php_http_message_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *return_value)
 {
-       php_http_message_object_t *obj = zend_object_store_get_object(object TSRMLS_CC);
+       php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object);
        php_http_message_object_prophandler_t *handler;
-       zval *return_value, *copy = php_http_ztyp(IS_STRING, member);
+       zend_string *member_name = zval_get_string(member);
 
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
-       if (SUCCESS == php_http_message_object_get_prophandler(Z_STRVAL_P(copy), Z_STRLEN_P(copy), &handler)) {
-               ALLOC_ZVAL(return_value);
-               Z_SET_REFCOUNT_P(return_value, 0);
-               Z_UNSET_ISREF_P(return_value);
-
+       if ((handler = php_http_message_object_get_prophandler(member_name))) {
                if (type == BP_VAR_R) {
-                       handler->read(obj, return_value TSRMLS_CC);
+                       handler->read(obj, return_value);
                } else {
-                       php_property_proxy_t *proxy = php_property_proxy_init(object, Z_STRVAL_P(copy), Z_STRLEN_P(copy) TSRMLS_CC);
-                       RETVAL_OBJVAL(php_property_proxy_object_new_ex(php_property_proxy_get_class_entry(), proxy, NULL TSRMLS_CC), 0);
+                       php_property_proxy_t *proxy = php_property_proxy_init(object, member_name);
+                       RETVAL_OBJ(&php_property_proxy_object_new_ex(php_property_proxy_get_class_entry(), proxy)->zo);
                }
        } else {
-               return_value = zend_get_std_object_handlers()->read_property(object, member, type PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC);
+               zend_get_std_object_handlers()->read_property(object, member, type, cache_slot, return_value);
        }
 
-       zval_ptr_dtor(&copy);
+       zend_string_release(member_name);
 
        return return_value;
 }
 
-static void php_http_message_object_write_prop(zval *object, zval *member, zval *value PHP_HTTP_ZEND_LITERAL_DC TSRMLS_DC)
+static void php_http_message_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot)
 {
-       php_http_message_object_t *obj = zend_object_store_get_object(object TSRMLS_CC);
+       php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object);
        php_http_message_object_prophandler_t *handler;
-       zval *copy = php_http_ztyp(IS_STRING, member);
+       zend_string *member_name = zval_get_string(member);
 
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
-       if (SUCCESS == php_http_message_object_get_prophandler(Z_STRVAL_P(copy), Z_STRLEN_P(copy), &handler)) {
-               handler->write(obj, value TSRMLS_CC);
+       if ((handler = php_http_message_object_get_prophandler(member_name))) {
+               handler->write(obj, value);
        } else {
-               zend_get_std_object_handlers()->write_property(object, member, value PHP_HTTP_ZEND_LITERAL_CC TSRMLS_CC);
+               zend_get_std_object_handlers()->write_property(object, member, value, cache_slot);
        }
 
-       zval_ptr_dtor(&copy);
+       zend_string_release(member_name);
 }
 
-static HashTable *php_http_message_object_get_props(zval *object TSRMLS_DC)
+static HashTable *php_http_message_object_get_props(zval *object)
 {
-       zval *headers;
-       php_http_message_object_t *obj = zend_object_store_get_object(object TSRMLS_CC);
-       HashTable *props = zend_get_std_object_handlers()->get_properties(object TSRMLS_CC);
-       zval array, *parent, *body;
+       zval tmp;
+       php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object);
+       HashTable *props = zend_get_std_object_handlers()->get_properties(object);
        char *ver_str, *url_str = NULL;
        size_t ver_len, url_len = 0;
 
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
-       INIT_PZVAL_ARRAY(&array, props);
        
-#define ASSOC_PROP(ptype, n, val) \
-       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) \
+#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_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(props, pi->name, &tmp); \
                } \
        } while(0)
 
-       ASSOC_PROP(long, "type", obj->message->type);
+       UPDATE_PROP("type", ZVAL_LONG(&tmp, obj->message->type));
+
        ver_len = spprintf(&ver_str, 0, "%u.%u", obj->message->http.version.major, obj->message->http.version.minor);
-       ASSOC_STRINGL_EX("httpVersion", ver_str, ver_len, 0);
+       UPDATE_PROP("httpVersion", ZVAL_STR(&tmp, php_http_cs2zs(ver_str, ver_len)));
 
        switch (obj->message->type) {
                case PHP_HTTP_REQUEST:
-                       ASSOC_PROP(long, "responseCode", 0);
-                       ASSOC_STRINGL("responseStatus", "", 0);
-                       ASSOC_STRING("requestMethod", STR_PTR(obj->message->http.info.request.method));
+                       UPDATE_PROP("responseCode", ZVAL_LONG(&tmp, 0));
+                       UPDATE_PROP("responseStatus", ZVAL_EMPTY_STRING(&tmp));
+                       UPDATE_PROP("requestMethod", ZVAL_STRING(&tmp, STR_PTR(obj->message->http.info.request.method)));
                        if (obj->message->http.info.request.url) {
                                php_http_url_to_string(obj->message->http.info.request.url, &url_str, &url_len, 0);
-                               ASSOC_STRINGL_EX("requestUrl", url_str, url_len, 0);
+                               UPDATE_PROP("requestUrl", ZVAL_STR(&tmp, php_http_cs2zs(url_str, url_len)));
                        } else {
-                               ASSOC_STRINGL("requestUrl", "", 0);
+                               UPDATE_PROP("requestUrl", ZVAL_EMPTY_STRING(&tmp));
                        }
 
                        break;
 
                case PHP_HTTP_RESPONSE:
-                       ASSOC_PROP(long, "responseCode", obj->message->http.info.response.code);
-                       ASSOC_STRING("responseStatus", STR_PTR(obj->message->http.info.response.status));
-                       ASSOC_STRINGL("requestMethod", "", 0);
-                       ASSOC_STRINGL("requestUrl", "", 0);
+                       UPDATE_PROP("responseCode", ZVAL_LONG(&tmp, obj->message->http.info.response.code));
+                       UPDATE_PROP("responseStatus", ZVAL_STRING(&tmp, STR_PTR(obj->message->http.info.response.status)));
+                       UPDATE_PROP("requestMethod", ZVAL_EMPTY_STRING(&tmp));
+                       UPDATE_PROP("requestUrl", ZVAL_EMPTY_STRING(&tmp));
                        break;
 
                case PHP_HTTP_NONE:
                default:
-                       ASSOC_PROP(long, "responseCode", 0);
-                       ASSOC_STRINGL("responseStatus", "", 0);
-                       ASSOC_STRINGL("requestMethod", "", 0);
-                       ASSOC_STRINGL("requestUrl", "", 0);
+                       UPDATE_PROP("responseCode", ZVAL_LONG(&tmp, 0));
+                       UPDATE_PROP("responseStatus", ZVAL_EMPTY_STRING(&tmp));
+                       UPDATE_PROP("requestMethod", ZVAL_EMPTY_STRING(&tmp));
+                       UPDATE_PROP("requestUrl", ZVAL_EMPTY_STRING(&tmp));
                        break;
        }
 
-       MAKE_STD_ZVAL(headers);
-       array_init(headers);
-       zend_hash_copy(Z_ARRVAL_P(headers), &obj->message->hdrs, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
-       ASSOC_PROP(zval, "headers", headers);
+       UPDATE_PROP("headers",
+                       array_init(&tmp);
+                       array_copy(&obj->message->hdrs, Z_ARRVAL(tmp));
+       );
 
-       MAKE_STD_ZVAL(body);
-       if (obj->body) {
-               ZVAL_OBJVAL(body, obj->body->zv, 1);
-       } else {
-               ZVAL_NULL(body);
-       }
-       ASSOC_PROP(zval, "body", body);
+       UPDATE_PROP("body",
+                       if (obj->body) {
+                               ZVAL_OBJECT(&tmp, &obj->body->zo, 1);
+                       } else {
+                               ZVAL_NULL(&tmp);
+                       }
+       );
 
-       MAKE_STD_ZVAL(parent);
-       if (obj->message->parent) {
-               ZVAL_OBJVAL(parent, obj->parent->zv, 1);
-       } else {
-               ZVAL_NULL(parent);
-       }
-       ASSOC_PROP(zval, "parentMessage", parent);
+       UPDATE_PROP("parentMessage",
+                       if (obj->message->parent) {
+                               ZVAL_OBJECT(&tmp, &obj->parent->zo, 1);
+                       } else {
+                               ZVAL_NULL(&tmp);
+                       }
+       );
 
        return props;
 }
@@ -1034,22 +974,22 @@ static PHP_METHOD(HttpMessage, __construct)
        zend_bool greedy = 1;
        zval *zmessage = NULL;
        php_http_message_t *msg = NULL;
-       php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
        zend_error_handling zeh;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z!b", &zmessage, &greedy), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|z!b", &zmessage, &greedy), invalid_arg, return);
 
-       zend_replace_error_handling(EH_THROW, php_http_exception_bad_message_class_entry, &zeh TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, php_http_exception_bad_message_class_entry, &zeh);
        if (zmessage && Z_TYPE_P(zmessage) == IS_RESOURCE) {
                php_stream *s;
                php_http_message_parser_t p;
                zend_error_handling zeh;
 
-               zend_replace_error_handling(EH_THROW, php_http_exception_unexpected_val_class_entry, &zeh TSRMLS_CC);
-               php_stream_from_zval(s, &zmessage);
-               zend_restore_error_handling(&zeh TSRMLS_CC);
+               zend_replace_error_handling(EH_THROW, php_http_exception_unexpected_val_class_entry, &zeh);
+               php_stream_from_zval(s, zmessage);
+               zend_restore_error_handling(&zeh);
 
-               if (s && php_http_message_parser_init(&p TSRMLS_CC)) {
+               if (s && php_http_message_parser_init(&p)) {
                        unsigned flags = (greedy ? PHP_HTTP_MESSAGE_PARSER_GREEDY : 0);
                        php_http_buffer_t buf;
 
@@ -1067,23 +1007,24 @@ static PHP_METHOD(HttpMessage, __construct)
                        php_http_throw(bad_message, "Empty message received from stream", NULL);
                }
        } else if (zmessage) {
-               zmessage = php_http_ztyp(IS_STRING, zmessage);
-               msg = php_http_message_parse(NULL, Z_STRVAL_P(zmessage), Z_STRLEN_P(zmessage), greedy TSRMLS_CC);
+               zend_string *zs_msg = zval_get_string(zmessage);
+
+               msg = php_http_message_parse(NULL, zs_msg->val, zs_msg->len, greedy);
 
                if (!msg && !EG(exception)) {
-                       php_http_throw(bad_message, "Could not parse message: %.*s", MIN(25, Z_STRLEN_P(zmessage)), Z_STRVAL_P(zmessage));
+                       php_http_throw(bad_message, "Could not parse message: %.*s", MIN(25, zs_msg->len), zs_msg->len);
                }
-               zval_ptr_dtor(&zmessage);
+               zend_string_release(zs_msg);
        }
 
        if (msg) {
                php_http_message_dtor(obj->message);
                obj->message = msg;
                if (obj->message->parent) {
-                       php_http_message_object_new_ex(Z_OBJCE_P(getThis()), obj->message->parent, &obj->parent TSRMLS_CC);
+                       obj->parent = php_http_message_object_new_ex(obj->zo.ce, obj->message->parent);
                }
        }
-       zend_restore_error_handling(&zeh TSRMLS_CC);
+       zend_restore_error_handling(&zeh);
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 }
 
@@ -1095,8 +1036,7 @@ static PHP_METHOD(HttpMessage, getBody)
 
        php_http_expect(SUCCESS == zend_parse_parameters_none(), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
+       obj = PHP_HTTP_OBJ(NULL, getThis());
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
        if (!obj->body) {
@@ -1104,7 +1044,7 @@ static PHP_METHOD(HttpMessage, getBody)
 
        }
        if (obj->body) {
-               RETVAL_OBJVAL(obj->body->zv, 1);
+               RETVAL_OBJECT(&obj->body->zo, 1);
        }
 }
 
@@ -1115,13 +1055,13 @@ static PHP_METHOD(HttpMessage, setBody)
 {
        zval *zbody;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &zbody, php_http_message_body_class_entry)) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &zbody, php_http_message_body_class_entry)) {
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
-               php_http_message_object_prophandler_set_body(obj, zbody TSRMLS_CC);
+               php_http_message_object_prophandler_set_body(obj, zbody);
        }
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_addBody, 0, 0, 1)
@@ -1131,14 +1071,14 @@ static PHP_METHOD(HttpMessage, addBody)
 {
        zval *new_body;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &new_body, php_http_message_body_class_entry)) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-               php_http_message_body_object_t *new_obj = zend_object_store_get_object(new_body TSRMLS_CC);
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &new_body, php_http_message_body_class_entry)) {
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
+               php_http_message_body_object_t *new_obj = PHP_HTTP_OBJ(NULL, new_body);
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
                php_http_message_body_to_callback(new_obj->body, (php_http_pass_callback_t) php_http_message_body_append, obj->message->body, 0, 0);
        }
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_getHeader, 0, 0, 1)
@@ -1148,37 +1088,33 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, getHeader)
 {
        char *header_str;
-       int header_len;
+       size_t header_len;
        zend_class_entry *header_ce = NULL;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|C!", &header_str, &header_len, &header_ce)) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "s|C!", &header_str, &header_len, &header_ce)) {
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
                zval *header;
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
-               if ((header = php_http_message_header(obj->message, header_str, header_len, 0))) {
+               if ((header = php_http_message_header(obj->message, header_str, header_len))) {
                        if (!header_ce) {
                                RETURN_ZVAL(header, 1, 1);
-                       } else if (instanceof_function(header_ce, php_http_header_class_entry TSRMLS_CC)) {
-                               zval *header_name, **argv[2];
-
-                               MAKE_STD_ZVAL(header_name);
-                               ZVAL_STRINGL(header_name, header_str, header_len, 1);
-                               Z_ADDREF_P(header);
+                       } else if (instanceof_function(header_ce, php_http_header_class_entry)) {
+                               zval argv[2];
 
-                               argv[0] = &header_name;
-                               argv[1] = &header;
+                               ZVAL_STRINGL(&argv[0], header_str, header_len);
+                               ZVAL_COPY(&argv[1], header);
 
                                object_init_ex(return_value, header_ce);
-                               php_http_method_call(return_value, ZEND_STRL("__construct"), 2, argv, NULL TSRMLS_CC);
+                               php_http_method_call(return_value, ZEND_STRL("__construct"), 2, argv, NULL);
 
-                               zval_ptr_dtor(&header_name);
-                               zval_ptr_dtor(&header);
+                               zval_ptr_dtor(&argv[0]);
+                               zval_ptr_dtor(&argv[1]);
 
                                return;
                        } else {
-                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Class '%s' is not as descendant of http\\Header", header_ce->name);
+                               php_error_docref(NULL, E_WARNING, "Class '%s' is not as descendant of http\\Header", header_ce->name->val);
                        }
                }
        }
@@ -1190,7 +1126,7 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, getHeaders)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
@@ -1207,23 +1143,23 @@ static PHP_METHOD(HttpMessage, setHeader)
 {
        zval *zvalue = NULL;
        char *name_str;
-       int name_len;
+       size_t name_len;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z!", &name_str, &name_len, &zvalue)) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!", &name_str, &name_len, &zvalue)) {
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
                char *name = php_http_pretty_key(estrndup(name_str, name_len), name_len, 1, 1);
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
                if (!zvalue) {
-                       zend_symtable_del(&obj->message->hdrs, name, name_len + 1);
+                       zend_symtable_str_del(&obj->message->hdrs, name, name_len);
                } else {
-                       Z_ADDREF_P(zvalue);
-                       zend_symtable_update(&obj->message->hdrs, name, name_len + 1, &zvalue, sizeof(void *), NULL);
+                       Z_TRY_ADDREF_P(zvalue);
+                       zend_symtable_str_update(&obj->message->hdrs, name, name_len, zvalue);
                }
                efree(name);
        }
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_setHeaders, 0, 0, 1)
@@ -1233,8 +1169,8 @@ static PHP_METHOD(HttpMessage, setHeaders)
 {
        zval *new_headers = NULL;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/!", &new_headers)) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "a/!", &new_headers)) {
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
@@ -1243,7 +1179,7 @@ static PHP_METHOD(HttpMessage, setHeaders)
                        array_join(Z_ARRVAL_P(new_headers), &obj->message->hdrs, 0, ARRAY_JOIN_PRETTIFY|ARRAY_JOIN_STRONLY);
                }
        }
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_addHeader, 0, 0, 2)
@@ -1254,26 +1190,25 @@ static PHP_METHOD(HttpMessage, addHeader)
 {
        zval *zvalue;
        char *name_str;
-       int name_len;
+       size_t name_len;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &name_str, &name_len, &zvalue)) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "sz", &name_str, &name_len, &zvalue)) {
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
                char *name = php_http_pretty_key(estrndup(name_str, name_len), name_len, 1, 1);
                zval *header;
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
-               Z_ADDREF_P(zvalue);
-               if ((header = php_http_message_header(obj->message, name, name_len, 0))) {
+               Z_TRY_ADDREF_P(zvalue);
+               if ((header = php_http_message_header(obj->message, name, name_len))) {
                        convert_to_array(header);
-                       zend_hash_next_index_insert(Z_ARRVAL_P(header), &zvalue, sizeof(void *), NULL);
-                       zval_ptr_dtor(&header);
+                       zend_hash_next_index_insert(Z_ARRVAL_P(header), zvalue);
                } else {
-                       zend_symtable_update(&obj->message->hdrs, name, name_len + 1, &zvalue, sizeof(void *), NULL);
+                       zend_symtable_str_update(&obj->message->hdrs, name, name_len, zvalue);
                }
                efree(name);
        }
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_addHeaders, 0, 0, 1)
@@ -1285,14 +1220,14 @@ static PHP_METHOD(HttpMessage, addHeaders)
        zval *new_headers;
        zend_bool append = 0;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|b", &new_headers, &append)) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "a|b", &new_headers, &append)) {
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
                array_join(Z_ARRVAL_P(new_headers), &obj->message->hdrs, append, ARRAY_JOIN_STRONLY|ARRAY_JOIN_PRETTIFY);
        }
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_getType, 0, 0, 0)
@@ -1300,7 +1235,7 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, getType)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
@@ -1313,16 +1248,16 @@ ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_setType, 0, 0, 1)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, setType)
 {
-       long type;
+       zend_long type;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &type)) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &type)) {
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
                php_http_message_set_type(obj->message, type);
        }
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_getInfo, 0, 0, 0)
@@ -1330,26 +1265,27 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, getInfo)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               char *tmp = NULL;
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+               char *str, *tmp = NULL;
+               size_t len;
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
                switch (obj->message->type) {
                        case PHP_HTTP_REQUEST:
-                               Z_STRLEN_P(return_value) = spprintf(&Z_STRVAL_P(return_value), 0, PHP_HTTP_INFO_REQUEST_FMT_ARGS(&obj->message->http, tmp, ""));
+                               len = spprintf(&str, 0, PHP_HTTP_INFO_REQUEST_FMT_ARGS(&obj->message->http, tmp, ""));
                                PTR_FREE(tmp);
                                break;
                        case PHP_HTTP_RESPONSE:
-                               Z_STRLEN_P(return_value) = spprintf(&Z_STRVAL_P(return_value), 0, PHP_HTTP_INFO_RESPONSE_FMT_ARGS(&obj->message->http, tmp, ""));
+                               len = spprintf(&str, 0, PHP_HTTP_INFO_RESPONSE_FMT_ARGS(&obj->message->http, tmp, ""));
                                PTR_FREE(tmp);
                                break;
                        default:
                                RETURN_NULL();
                                break;
                }
-               Z_TYPE_P(return_value) = IS_STRING;
-               return;
+
+               RETVAL_STR(php_http_cs2zs(str, len));
        }
 }
 
@@ -1359,16 +1295,16 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, setInfo)
 {
        char *str;
-       int len;
+       size_t len;
        php_http_message_object_t *obj;
        php_http_info_t inf;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &len), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &str, &len), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
-       if (!php_http_info_parse(&inf, str TSRMLS_CC)) {
+       if (!php_http_info_parse(&inf, str)) {
                php_http_throw(bad_header, "Could not parse message info '%s'", str);
                return;
        }
@@ -1376,7 +1312,7 @@ static PHP_METHOD(HttpMessage, setInfo)
        php_http_message_set_info(obj->message, &inf);
        php_http_info_dtor(&inf);
 
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_getHttpVersion, 0, 0, 0)
@@ -1386,12 +1322,12 @@ static PHP_METHOD(HttpMessage, getHttpVersion)
        if (SUCCESS == zend_parse_parameters_none()) {
                char *str;
                size_t len;
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
-               php_http_version_to_string(&obj->message->http.version, &str, &len, NULL, NULL TSRMLS_CC);
-               RETURN_STRINGL(str, len, 0);
+               php_http_version_to_string(&obj->message->http.version, &str, &len, NULL, NULL);
+               RETURN_STR(php_http_cs2zs(str, len));
        }
 }
 
@@ -1401,20 +1337,20 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, setHttpVersion)
 {
        char *v_str;
-       int v_len;
+       size_t v_len;
        php_http_version_t version;
        php_http_message_object_t *obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &v_str, &v_len), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &v_str, &v_len), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
-       php_http_expect(php_http_version_parse(&version, v_str TSRMLS_CC), unexpected_val, return);
+       php_http_expect(php_http_version_parse(&version, v_str), unexpected_val, return);
 
        obj->message->http.version = version;
 
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_getResponseCode, 0, 0, 0)
@@ -1422,12 +1358,12 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, getResponseCode)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
                if (obj->message->type != PHP_HTTP_RESPONSE) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "http\\Message is not if type response");
+                       php_error_docref(NULL, E_WARNING, "http\\Message is not if type response");
                        RETURN_FALSE;
                }
 
@@ -1441,14 +1377,13 @@ ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_setResponseCode, 0, 0, 1)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, setResponseCode)
 {
-       long code;
+       zend_long code;
        zend_bool strict = 1;
        php_http_message_object_t *obj;
 
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|b", &code, &strict), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
+       obj = PHP_HTTP_OBJ(NULL, getThis());
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
        if (obj->message->type != PHP_HTTP_RESPONSE) {
@@ -1464,7 +1399,7 @@ static PHP_METHOD(HttpMessage, setResponseCode)
        obj->message->http.info.response.code = code;
        PTR_SET(obj->message->http.info.response.status, estrdup(php_http_env_get_response_status_for_code(code)));
 
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_getResponseStatus, 0, 0, 0)
@@ -1472,16 +1407,16 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, getResponseStatus)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
                if (obj->message->type != PHP_HTTP_RESPONSE) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "http\\Message is not of type response");
+                       php_error_docref(NULL, E_WARNING, "http\\Message is not of type response");
                }
 
                if (obj->message->http.info.response.status) {
-                       RETURN_STRING(obj->message->http.info.response.status, 1);
+                       RETURN_STRING(obj->message->http.info.response.status);
                } else {
                        RETURN_EMPTY_STRING();
                }
@@ -1499,7 +1434,7 @@ static PHP_METHOD(HttpMessage, setResponseStatus)
 
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &status, &status_len), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
@@ -1508,7 +1443,7 @@ static PHP_METHOD(HttpMessage, setResponseStatus)
        }
 
        PTR_SET(obj->message->http.info.response.status, estrndup(status, status_len));
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_getRequestMethod, 0, 0, 0)
@@ -1516,17 +1451,17 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, getRequestMethod)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
                if (obj->message->type != PHP_HTTP_REQUEST) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "http\\Message is not of type request");
+                       php_error_docref(NULL, E_WARNING, "http\\Message is not of type request");
                        RETURN_FALSE;
                }
 
                if (obj->message->http.info.request.method) {
-                       RETURN_STRING(obj->message->http.info.request.method, 1);
+                       RETURN_STRING(obj->message->http.info.request.method);
                } else {
                        RETURN_EMPTY_STRING();
                }
@@ -1539,12 +1474,12 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, setRequestMethod)
 {
        char *method;
-       int method_len;
+       size_t method_len;
        php_http_message_object_t *obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &method, &method_len), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &method, &method_len), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
@@ -1559,7 +1494,7 @@ static PHP_METHOD(HttpMessage, setRequestMethod)
        }
 
        PTR_SET(obj->message->http.info.request.method, estrndup(method, method_len));
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_getRequestUrl, 0, 0, 0)
@@ -1567,12 +1502,12 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, getRequestUrl)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
                if (obj->message->type != PHP_HTTP_REQUEST) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "http\\Message is not of type request");
+                       php_error_docref(NULL, E_WARNING, "http\\Message is not of type request");
                        RETURN_FALSE;
                }
 
@@ -1581,7 +1516,7 @@ static PHP_METHOD(HttpMessage, getRequestUrl)
                        size_t url_len;
 
                        php_http_url_to_string(obj->message->http.info.request.url, &url_str, &url_len, 0);
-                       RETURN_STRINGL(url_str, url_len, 0);
+                       RETURN_STR(php_http_cs2zs(url_str, url_len));
                } else {
                        RETURN_EMPTY_STRING();
                }
@@ -1598,9 +1533,9 @@ static PHP_METHOD(HttpMessage, setRequestUrl)
        php_http_message_object_t *obj;
        zend_error_handling zeh;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zurl), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "z", &zurl), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
 
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
@@ -1609,9 +1544,9 @@ static PHP_METHOD(HttpMessage, setRequestUrl)
                return;
        }
 
-       zend_replace_error_handling(EH_THROW, php_http_exception_bad_url_class_entry, &zeh TSRMLS_CC);
-       url = php_http_url_from_zval(zurl, ~0 TSRMLS_CC);
-       zend_restore_error_handling(&zeh TSRMLS_CC);
+       zend_replace_error_handling(EH_THROW, php_http_exception_bad_url_class_entry, &zeh);
+       url = php_http_url_from_zval(zurl, ~0);
+       zend_restore_error_handling(&zeh);
 
        if (php_http_url_is_empty(url)) {
                php_http_url_free(&url);
@@ -1620,7 +1555,7 @@ static PHP_METHOD(HttpMessage, setRequestUrl)
                PTR_SET(obj->message->http.info.request.url, url);
        }
 
-       RETVAL_ZVAL(getThis(), 1, 0);
+       RETVAL_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_getParentMessage, 0, 0, 0)
@@ -1631,8 +1566,7 @@ static PHP_METHOD(HttpMessage, getParentMessage)
 
        php_http_expect(SUCCESS == zend_parse_parameters_none(), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
+       obj = PHP_HTTP_OBJ(NULL, getThis());
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
        if (!obj->message->parent) {
@@ -1640,7 +1574,7 @@ static PHP_METHOD(HttpMessage, getParentMessage)
                return;
        }
 
-       RETVAL_OBJVAL(obj->parent->zv, 1);
+       RETVAL_OBJECT(&obj->parent->zo, 1);
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage___toString, 0, 0, 0)
@@ -1652,8 +1586,8 @@ static PHP_METHOD(HttpMessage, toString)
 {
        zend_bool include_parent = 0;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &include_parent)) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &include_parent)) {
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
                char *string;
                size_t length;
 
@@ -1665,7 +1599,7 @@ static PHP_METHOD(HttpMessage, toString)
                        php_http_message_to_string(obj->message, &string, &length);
                }
                if (string) {
-                       RETURN_STRINGL(string, length, 0);
+                       RETURN_STR(php_http_cs2zs(string, length));
                }
        }
        RETURN_EMPTY_STRING();
@@ -1678,13 +1612,13 @@ static PHP_METHOD(HttpMessage, toStream)
 {
        zval *zstream;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream)) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zstream)) {
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
                php_stream *s;
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
-               php_stream_from_zval(s, &zstream);
+               php_stream_from_zval(s, zstream);
                php_http_message_to_callback(obj->message, (php_http_pass_callback_t) _php_stream_write, s);
        }
 }
@@ -1696,20 +1630,17 @@ static PHP_METHOD(HttpMessage, toCallback)
 {
        php_http_pass_fcall_arg_t fcd;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f", &fcd.fci, &fcd.fcc)) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "f", &fcd.fci, &fcd.fcc)) {
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
-               fcd.fcz = getThis();
-               Z_ADDREF_P(fcd.fcz);
-               TSRMLS_SET_CTX(fcd.ts);
-
+               ZVAL_COPY(&fcd.fcz, getThis());
                php_http_message_to_callback(obj->message, php_http_pass_fcall_callback, &fcd);
                zend_fcall_info_args_clear(&fcd.fci, 1);
-
                zval_ptr_dtor(&fcd.fcz);
-               RETURN_ZVAL(getThis(), 1, 0);
+
+               RETURN_ZVAL_FAST(getThis());
        }
 }
 
@@ -1718,14 +1649,14 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, serialize)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
                char *string;
                size_t length;
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
                php_http_message_serialize(obj->message, &string, &length);
-               RETURN_STRINGL(string, length, 0);
+               RETURN_STR(php_http_cs2zs(string, length));
        }
        RETURN_EMPTY_STRING();
 }
@@ -1735,21 +1666,22 @@ ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_unserialize, 0, 0, 1)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, unserialize)
 {
-       int length;
+       size_t length;
        char *serialized;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &serialized, &length)) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &serialized, &length)) {
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
                php_http_message_t *msg;
 
                if (obj->message) {
+                       /* do not free recursively */
                        php_http_message_dtor(obj->message);
                        efree(obj->message);
                }
-               if ((msg = php_http_message_parse(NULL, serialized, (size_t) length, 1 TSRMLS_CC))) {
+               if ((msg = php_http_message_parse(NULL, serialized, length, 1))) {
                        obj->message = msg;
                } else {
-                       obj->message = php_http_message_init(NULL, 0, NULL TSRMLS_CC);
+                       obj->message = php_http_message_init(NULL, 0, NULL);
                        php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not unserialize http\\Message");
                }
        }
@@ -1759,15 +1691,18 @@ ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_detach, 0, 0, 0)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, detach)
 {
-       php_http_message_object_t *obj;
+       php_http_message_object_t *obj, *new_obj;
+       php_http_message_t *msg_cpy;
 
        php_http_expect(SUCCESS == zend_parse_parameters_none(), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
+       obj = PHP_HTTP_OBJ(NULL, getThis());
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
-       RETVAL_OBJVAL(php_http_message_object_new_ex(obj->zo.ce, php_http_message_copy_ex(obj->message, NULL, 0), NULL TSRMLS_CC), 0);
+       msg_cpy = php_http_message_copy_ex(obj->message, NULL, 0);
+       new_obj = php_http_message_object_new_ex(obj->zo.ce, msg_cpy);
+
+       RETVAL_OBJ(&new_obj->zo);
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_prepend, 0, 0, 1)
@@ -1781,11 +1716,11 @@ static PHP_METHOD(HttpMessage, prepend)
        php_http_message_t *msg[2];
        php_http_message_object_t *obj, *prepend_obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|b", &prepend, php_http_message_class_entry, &top), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O|b", &prepend, php_http_message_class_entry, &top), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       obj = PHP_HTTP_OBJ(NULL, getThis());
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
-       prepend_obj = zend_object_store_get_object(prepend TSRMLS_CC);
+       prepend_obj = PHP_HTTP_OBJ(NULL, prepend);
        PHP_HTTP_MESSAGE_OBJECT_INIT(prepend_obj);
 
        /* safety check */
@@ -1798,8 +1733,8 @@ static PHP_METHOD(HttpMessage, prepend)
                }
        }
 
-       php_http_message_object_prepend(getThis(), prepend, top TSRMLS_CC);
-       RETURN_ZVAL(getThis(), 1, 0);
+       php_http_message_object_prepend(getThis(), prepend, top);
+       RETURN_ZVAL_FAST(getThis());
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_reverse, 0, 0, 0)
@@ -1808,7 +1743,7 @@ static PHP_METHOD(HttpMessage, reverse)
 {
        php_http_expect(SUCCESS == zend_parse_parameters_none(), invalid_arg, return);
 
-       php_http_message_object_reverse(getThis(), return_value TSRMLS_CC);
+       php_http_message_object_reverse(getThis(), return_value);
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_isMultipart, 0, 0, 0)
@@ -1818,17 +1753,21 @@ static PHP_METHOD(HttpMessage, isMultipart)
 {
        zval *zboundary = NULL;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z", &zboundary)) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|z!", &zboundary)) {
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
                char *boundary = NULL;
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
-               RETVAL_BOOL(php_http_message_is_multipart(obj->message, zboundary ? &boundary : NULL));
+               if (php_http_message_is_multipart(obj->message, zboundary ? &boundary : NULL)) {
+                       RETVAL_TRUE;
+               } else {
+                       RETVAL_FALSE;
+               }
 
                if (zboundary && boundary) {
                        zval_dtor(zboundary);
-                       ZVAL_STRING(zboundary, boundary, 0);
+                       ZVAL_STR(zboundary, php_http_cs2zs(boundary, strlen(boundary)));
                }
        }
 }
@@ -1843,8 +1782,7 @@ static PHP_METHOD(HttpMessage, splitMultipartBody)
 
        php_http_expect(SUCCESS == zend_parse_parameters_none(), invalid_arg, return);
 
-       obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
+       obj = PHP_HTTP_OBJ(NULL, getThis());
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
        if (!php_http_message_is_multipart(obj->message, &boundary)) {
@@ -1856,23 +1794,21 @@ static PHP_METHOD(HttpMessage, splitMultipartBody)
 
        PTR_FREE(boundary);
 
-       RETURN_OBJVAL(php_http_message_object_new_ex(php_http_message_class_entry, msg, NULL TSRMLS_CC), 0);
+       RETURN_OBJ(&php_http_message_object_new_ex(obj->zo.ce, msg)->zo);
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_count, 0, 0, 0)
 ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, count)
 {
-       long count_mode = -1;
+       zend_long count_mode = -1;
 
        if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &count_mode)) {
-               long i = 0;
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
 
-               php_http_message_count(i, obj->message);
-               RETURN_LONG(i);
+               RETURN_LONG(php_http_message_count(obj->message));
        }
 }
 
@@ -1882,13 +1818,12 @@ static PHP_METHOD(HttpMessage, rewind)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
                zval *zobj = getThis();
-               php_http_message_object_t *obj = zend_object_store_get_object(zobj TSRMLS_CC);
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
-               if (obj->iterator) {
+               if (!Z_ISUNDEF(obj->iterator)) {
                        zval_ptr_dtor(&obj->iterator);
                }
-               Z_ADDREF_P(zobj);
-               obj->iterator = zobj;
+               ZVAL_COPY(&obj->iterator, zobj);
        }
 }
 
@@ -1897,9 +1832,9 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, valid)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
-               RETURN_BOOL(obj->iterator != NULL);
+               RETURN_BOOL(!Z_ISUNDEF(obj->iterator));
        }
 }
 
@@ -1908,19 +1843,20 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, next)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
-               if (obj->iterator) {
-                       php_http_message_object_t *itr = zend_object_store_get_object(obj->iterator TSRMLS_CC);
+               if (!Z_ISUNDEF(obj->iterator)) {
+                       php_http_message_object_t *itr = PHP_HTTP_OBJ(NULL, &obj->iterator);
 
-                       if (itr && itr->parent) {
-                               zval *old = obj->iterator;
-                               MAKE_STD_ZVAL(obj->iterator);
-                               ZVAL_OBJVAL(obj->iterator, itr->parent->zv, 1);
-                               zval_ptr_dtor(&old);
+                       if (itr->parent) {
+                               zval tmp;
+
+                               ZVAL_OBJECT(&tmp, &itr->parent->zo, 1);
+                               zval_ptr_dtor(&obj->iterator);
+                               obj->iterator = tmp;
                        } else {
                                zval_ptr_dtor(&obj->iterator);
-                               obj->iterator = NULL;
+                               ZVAL_UNDEF(&obj->iterator);
                        }
                }
        }
@@ -1931,9 +1867,9 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, key)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
-               RETURN_LONG(obj->iterator ? obj->iterator->value.obj.handle:0);
+               RETURN_LONG(Z_ISUNDEF(obj->iterator) ? 0 : Z_OBJ_HANDLE(obj->iterator));
        }
 }
 
@@ -1942,10 +1878,10 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(HttpMessage, current)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
-               php_http_message_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+               php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
-               if (obj->iterator) {
-                       RETURN_ZVAL(obj->iterator, 1, 0);
+               if (!Z_ISUNDEF(obj->iterator)) {
+                       RETURN_ZVAL_FAST(&obj->iterator);
                }
        }
 }
@@ -2013,40 +1949,42 @@ PHP_MINIT_FUNCTION(http_message)
        zend_class_entry ce = {0};
 
        INIT_NS_CLASS_ENTRY(ce, "http", "Message", php_http_message_methods);
-       php_http_message_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
+       php_http_message_class_entry = zend_register_internal_class(&ce);
        php_http_message_class_entry->create_object = php_http_message_object_new;
        memcpy(&php_http_message_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+       php_http_message_object_handlers.offset = XtOffsetOf(php_http_message_object_t, zo);
        php_http_message_object_handlers.clone_obj = php_http_message_object_clone;
+       php_http_message_object_handlers.dtor_obj = php_http_message_object_free;
        php_http_message_object_handlers.read_property = php_http_message_object_read_prop;
        php_http_message_object_handlers.write_property = php_http_message_object_write_prop;
        php_http_message_object_handlers.get_properties = php_http_message_object_get_props;
        php_http_message_object_handlers.get_property_ptr_ptr = NULL;
 
-       zend_class_implements(php_http_message_class_entry TSRMLS_CC, 3, spl_ce_Countable, zend_ce_serializable, zend_ce_iterator);
+       zend_class_implements(php_http_message_class_entry, 3, spl_ce_Countable, zend_ce_serializable, zend_ce_iterator);
 
        zend_hash_init(&php_http_message_object_prophandlers, 9, NULL, NULL, 1);
-       zend_declare_property_long(php_http_message_class_entry, ZEND_STRL("type"), PHP_HTTP_NONE, ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_long(php_http_message_class_entry, ZEND_STRL("type"), PHP_HTTP_NONE, ZEND_ACC_PROTECTED);
        php_http_message_object_add_prophandler(ZEND_STRL("type"), php_http_message_object_prophandler_get_type, php_http_message_object_prophandler_set_type);
-       zend_declare_property_null(php_http_message_class_entry, ZEND_STRL("body"), ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_null(php_http_message_class_entry, ZEND_STRL("body"), ZEND_ACC_PROTECTED);
        php_http_message_object_add_prophandler(ZEND_STRL("body"), php_http_message_object_prophandler_get_body, php_http_message_object_prophandler_set_body);
-       zend_declare_property_string(php_http_message_class_entry, ZEND_STRL("requestMethod"), "", ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_string(php_http_message_class_entry, ZEND_STRL("requestMethod"), "", ZEND_ACC_PROTECTED);
        php_http_message_object_add_prophandler(ZEND_STRL("requestMethod"), php_http_message_object_prophandler_get_request_method, php_http_message_object_prophandler_set_request_method);
-       zend_declare_property_string(php_http_message_class_entry, ZEND_STRL("requestUrl"), "", ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_string(php_http_message_class_entry, ZEND_STRL("requestUrl"), "", ZEND_ACC_PROTECTED);
        php_http_message_object_add_prophandler(ZEND_STRL("requestUrl"), php_http_message_object_prophandler_get_request_url, php_http_message_object_prophandler_set_request_url);
-       zend_declare_property_string(php_http_message_class_entry, ZEND_STRL("responseStatus"), "", ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_string(php_http_message_class_entry, ZEND_STRL("responseStatus"), "", ZEND_ACC_PROTECTED);
        php_http_message_object_add_prophandler(ZEND_STRL("responseStatus"), php_http_message_object_prophandler_get_response_status, php_http_message_object_prophandler_set_response_status);
-       zend_declare_property_long(php_http_message_class_entry, ZEND_STRL("responseCode"), 0, ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_long(php_http_message_class_entry, ZEND_STRL("responseCode"), 0, ZEND_ACC_PROTECTED);
        php_http_message_object_add_prophandler(ZEND_STRL("responseCode"), php_http_message_object_prophandler_get_response_code, php_http_message_object_prophandler_set_response_code);
-       zend_declare_property_null(php_http_message_class_entry, ZEND_STRL("httpVersion"), ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_null(php_http_message_class_entry, ZEND_STRL("httpVersion"), ZEND_ACC_PROTECTED);
        php_http_message_object_add_prophandler(ZEND_STRL("httpVersion"), php_http_message_object_prophandler_get_http_version, php_http_message_object_prophandler_set_http_version);
-       zend_declare_property_null(php_http_message_class_entry, ZEND_STRL("headers"), ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_null(php_http_message_class_entry, ZEND_STRL("headers"), ZEND_ACC_PROTECTED);
        php_http_message_object_add_prophandler(ZEND_STRL("headers"), php_http_message_object_prophandler_get_headers, php_http_message_object_prophandler_set_headers);
-       zend_declare_property_null(php_http_message_class_entry, ZEND_STRL("parentMessage"), ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_null(php_http_message_class_entry, ZEND_STRL("parentMessage"), ZEND_ACC_PROTECTED);
        php_http_message_object_add_prophandler(ZEND_STRL("parentMessage"), php_http_message_object_prophandler_get_parent_message, php_http_message_object_prophandler_set_parent_message);
 
-       zend_declare_class_constant_long(php_http_message_class_entry, ZEND_STRL("TYPE_NONE"), PHP_HTTP_NONE TSRMLS_CC);
-       zend_declare_class_constant_long(php_http_message_class_entry, ZEND_STRL("TYPE_REQUEST"), PHP_HTTP_REQUEST TSRMLS_CC);
-       zend_declare_class_constant_long(php_http_message_class_entry, ZEND_STRL("TYPE_RESPONSE"), PHP_HTTP_RESPONSE TSRMLS_CC);
+       zend_declare_class_constant_long(php_http_message_class_entry, ZEND_STRL("TYPE_NONE"), PHP_HTTP_NONE);
+       zend_declare_class_constant_long(php_http_message_class_entry, ZEND_STRL("TYPE_REQUEST"), PHP_HTTP_REQUEST);
+       zend_declare_class_constant_long(php_http_message_class_entry, ZEND_STRL("TYPE_RESPONSE"), PHP_HTTP_RESPONSE);
 
        return SUCCESS;
 }
index 6524a27..2f99507 100644 (file)
@@ -14,6 +14,7 @@
 #define PHP_HTTP_MESSAGE_H
 
 #include "php_http_message_body.h"
+#include "php_http_header.h"
 
 /* required minimum length of an HTTP message "HTTP/1.1" */
 #define PHP_HTTP_MESSAGE_MIN_SIZE 8
@@ -28,17 +29,18 @@ struct php_http_message {
        php_http_message_body_t *body;
        php_http_message_t *parent;
        void *opaque;
-#ifdef ZTS
-       void ***ts;
-#endif
 };
 
-PHP_HTTP_API zend_bool php_http_message_info_callback(php_http_message_t **message, HashTable **headers, php_http_info_t *info TSRMLS_DC);
+PHP_HTTP_API zend_bool php_http_message_info_callback(php_http_message_t **message, HashTable **headers, php_http_info_t *info);
 
-PHP_HTTP_API php_http_message_t *php_http_message_init(php_http_message_t *m, php_http_message_type_t t, php_http_message_body_t *body TSRMLS_DC);
-PHP_HTTP_API php_http_message_t *php_http_message_init_env(php_http_message_t *m, php_http_message_type_t t TSRMLS_DC);
-PHP_HTTP_API php_http_message_t *php_http_message_copy(php_http_message_t *from, php_http_message_t *to);
+PHP_HTTP_API php_http_message_t *php_http_message_init(php_http_message_t *m, php_http_message_type_t t, php_http_message_body_t *body);
+PHP_HTTP_API php_http_message_t *php_http_message_init_env(php_http_message_t *m, php_http_message_type_t t);
 PHP_HTTP_API php_http_message_t *php_http_message_copy_ex(php_http_message_t *from, php_http_message_t *to, zend_bool parents);
+static inline php_http_message_t *php_http_message_copy(php_http_message_t *from, php_http_message_t *to)
+{
+       return php_http_message_copy_ex(from, to, 1);
+}
+
 PHP_HTTP_API void php_http_message_dtor(php_http_message_t *message);
 PHP_HTTP_API void php_http_message_free(php_http_message_t **message);
 
@@ -47,7 +49,18 @@ PHP_HTTP_API void php_http_message_set_info(php_http_message_t *message, php_htt
 
 PHP_HTTP_API void php_http_message_update_headers(php_http_message_t *msg);
 
-PHP_HTTP_API zval *php_http_message_header(php_http_message_t *msg, const char *key_str, size_t key_len, int join);
+PHP_HTTP_API zval *php_http_message_header(php_http_message_t *msg, const char *key_str, size_t key_len);
+
+static inline zend_string *php_http_message_header_string(php_http_message_t *msg, const char *key_str, size_t key_len)
+{
+       zval *header;
+
+       if ((header = php_http_message_header(msg, key_str, key_len))) {
+               return php_http_header_value_to_string(header);
+       }
+       return NULL;
+}
+
 PHP_HTTP_API zend_bool php_http_message_is_multipart(php_http_message_t *msg, char **boundary);
 
 PHP_HTTP_API void php_http_message_to_string(php_http_message_t *msg, char **string, size_t *length);
@@ -58,21 +71,25 @@ PHP_HTTP_API void php_http_message_serialize(php_http_message_t *message, char *
 PHP_HTTP_API php_http_message_t *php_http_message_reverse(php_http_message_t *msg);
 PHP_HTTP_API php_http_message_t *php_http_message_zip(php_http_message_t *one, php_http_message_t *two);
 
-#define php_http_message_count(c, m) \
-{ \
-       php_http_message_t *__tmp_msg = (m); \
-       for (c = 0; __tmp_msg; __tmp_msg = __tmp_msg->parent, ++(c)); \
+static inline size_t php_http_message_count(php_http_message_t *m)
+{
+       size_t c = 1;
+
+       while ((m = m->parent)) {
+               ++c;
+       }
+
+       return c;
 }
 
-PHP_HTTP_API php_http_message_t *php_http_message_parse(php_http_message_t *msg, const char *str, size_t len, zend_bool greedy TSRMLS_DC);
+PHP_HTTP_API php_http_message_t *php_http_message_parse(php_http_message_t *msg, const char *str, size_t len, zend_bool greedy);
 
 typedef struct php_http_message_object {
-       zend_object zo;
-       zend_object_value zv;
        php_http_message_t *message;
        struct php_http_message_object *parent;
        php_http_message_body_object_t *body;
-       zval *iterator;
+       zval iterator;
+       zend_object zo;
 } php_http_message_object_t;
 
 PHP_HTTP_API zend_class_entry *php_http_message_class_entry;
@@ -80,15 +97,15 @@ PHP_HTTP_API zend_class_entry *php_http_message_class_entry;
 PHP_MINIT_FUNCTION(http_message);
 PHP_MSHUTDOWN_FUNCTION(http_message);
 
-void php_http_message_object_prepend(zval *this_ptr, zval *prepend, zend_bool top /* = 1 */ TSRMLS_DC);
-void php_http_message_object_reverse(zval *this_ptr, zval *return_value TSRMLS_DC);
-STATUS php_http_message_object_set_body(php_http_message_object_t *obj, zval *zbody TSRMLS_DC);
-STATUS php_http_message_object_init_body_object(php_http_message_object_t *obj);
+void php_http_message_object_prepend(zval *this_ptr, zval *prepend, zend_bool top /* = 1 */);
+void php_http_message_object_reverse(zval *this_ptr, zval *return_value);
+ZEND_RESULT_CODE php_http_message_object_set_body(php_http_message_object_t *obj, zval *zbody);
+ZEND_RESULT_CODE php_http_message_object_init_body_object(php_http_message_object_t *obj);