cleanups & includes
authorMichael Wallner <mike@php.net>
Thu, 9 Sep 2010 09:10:32 +0000 (09:10 +0000)
committerMichael Wallner <mike@php.net>
Thu, 9 Sep 2010 09:10:32 +0000 (09:10 +0000)
23 files changed:
php_http.c
php_http_cookie.c
php_http_encoding.c
php_http_env.c
php_http_etag.c
php_http_exception.c
php_http_filter.c
php_http_header_parser.c
php_http_header_parser.h
php_http_headers.c
php_http_message.c
php_http_message_parser.h
php_http_misc.c
php_http_misc.h
php_http_negotiate.c
php_http_querystring.c
php_http_request.c
php_http_request.h
php_http_request_datashare.c
php_http_request_method.c
php_http_request_pool.c
php_http_url.c
php_http_url.h

index 273ef7b..47fba64 100644 (file)
 
 #include "php_http.h"
 
+#include <zlib.h>
+#include <curl/curl.h>
+#ifdef PHP_HTTP_HAVE_EVENT
+#      include <event.h>
+#endif
+
 #include <main/php_ini.h>
 #include <ext/standard/info.h>
 #include <Zend/zend_extensions.h>
@@ -176,8 +182,6 @@ PHP_RSHUTDOWN_FUNCTION(http)
        return SUCCESS;
 }
 
-
-
 PHP_MINFO_FUNCTION(http)
 {
        php_info_print_table_start();
@@ -190,22 +194,15 @@ PHP_MINFO_FUNCTION(http)
        php_info_print_table_start();
        php_info_print_table_header(3, "Used Library", "Compiled", "Linked");
        {
-#ifdef PHP_HTTP_HAVE_CURL
                curl_version_info_data *cv = curl_version_info(CURLVERSION_NOW);
+               php_info_print_table_row(3, "libz", ZLIB_VERSION, zlibVersion());
                php_info_print_table_row(3, "libcurl", LIBCURL_VERSION, cv->version);
-#else
-               php_info_print_table_row(3, "libcurl", "disabled", "disabled");
-#endif
 #ifdef PHP_HTTP_HAVE_EVENT
                php_info_print_table_row(3, "libevent", PHP_HTTP_EVENT_VERSION, event_get_version());
 #else
                php_info_print_table_row(3, "libevent", "disabled", "disabled");
 #endif
-#ifdef PHP_HTTP_HAVE_ZLIB
-               php_info_print_table_row(3, "libz", ZLIB_VERSION, zlibVersion());
-#else
                php_info_print_table_row(3, "libz", "disabled", "disabled");
-#endif
        }
        php_info_print_table_end();
        
index c23b608..42f7d13 100644 (file)
@@ -14,6 +14,8 @@
 
 #include "php_http.h"
 
+#include <ext/date/php_date.h>
+
 PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_init(php_http_cookie_list_t *list TSRMLS_DC)
 {
        if (!list) {
@@ -287,7 +289,7 @@ PHP_HTTP_API php_http_cookie_list_t *php_http_cookie_list_from_struct(php_http_c
 
 
 
-static inline void append_encoded(php_http_buffer *buf, const char *key, size_t key_len, const char *val, size_t val_len)
+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];
@@ -308,7 +310,7 @@ static inline void append_encoded(php_http_buffer *buf, const char *key, size_t
 
 PHP_HTTP_API void php_http_cookie_list_to_string(php_http_cookie_list_t *list, char **str, size_t *len TSRMLS_DC)
 {
-       php_http_buffer buf;
+       php_http_buffer_t buf;
        zval **val;
        php_http_array_hashkey_t key = php_http_array_hashkey_init(0);
        HashPosition pos;
index a300eb5..07a026d 100644 (file)
@@ -14,6 +14,8 @@
 
 #include "php_http.h"
 
+#include <zlib.h>
+
 static inline int eol_match(char **line, int *eol_len)
 {
        char *ptr = *line;
@@ -111,7 +113,7 @@ PHP_HTTP_API const char *php_http_encoding_dechunk(const char *encoded, size_t e
 static inline int php_http_inflate_rounds(z_stream *Z, int flush, char **buf, size_t *len)
 {
        int status = 0, round = 0;
-       php_http_buffer buffer;
+       php_http_buffer_t buffer;
        
        *buf = NULL;
        *len = 0;
@@ -339,7 +341,7 @@ PHP_HTTP_API void php_http_encoding_stream_free(php_http_encoding_stream_t **s)
 }
 
 struct dechunk_ctx {
-       php_http_buffer buffer;
+       php_http_buffer_t buffer;
        ulong hexlen;
        unsigned zeroed:1;
 };
@@ -516,17 +518,16 @@ retry_raw_inflate:
 
 static STATUS dechunk_update(php_http_encoding_stream_t *s, const char *data, size_t data_len, char **decoded, size_t *decoded_len)
 {
-       php_http_buffer tmp;
+       php_http_buffer_t tmp;
        struct dechunk_ctx *ctx = s->ctx;
        TSRMLS_FETCH_FROM_CTX(s->ts);
 
        if (ctx->zeroed) {
+               php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "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)) {
-               return FAILURE;
-       }
-       if (!php_http_buffer_fix(&ctx->buffer)) {
+       if ((PHP_HTTP_BUFFER_NOMEM == php_http_buffer_append(&ctx->buffer, data, data_len)) || !php_http_buffer_fix(&ctx->buffer)) {
+               /* OOM */
                return FAILURE;
        }
 
@@ -602,6 +603,7 @@ static STATUS dechunk_update(php_http_encoding_stream_t *s, const char *data, si
                                        /*      if strtoul() stops at the beginning of the buffered data
                                                there's domething oddly wrong, i.e. bad input */
                                        if (stop == PHP_HTTP_BUFFER_VAL(&ctx->buffer)) {
+                                               php_http_error(HE_WARNING, PHP_HTTP_E_ENCODING, "Failed to parse chunk len from '%.*s'", MIN(16, ctx->buffer.used), ctx->buffer.data);
                                                php_http_buffer_dtor(&tmp);
                                                return FAILURE;
                                        }
@@ -790,7 +792,7 @@ static void deflate_dtor(php_http_encoding_stream_t *s)
                z_streamp ctx = s->ctx;
 
                if (ctx->opaque) {
-                       php_http_buffer_free((php_http_buffer **) &ctx->opaque);
+                       php_http_buffer_free((php_http_buffer_t **) &ctx->opaque);
                }
                deflateEnd(ctx);
                pefree(ctx, (s->flags & PHP_HTTP_ENCODING_STREAM_PERSISTENT));
@@ -804,7 +806,7 @@ static void inflate_dtor(php_http_encoding_stream_t *s)
                z_streamp ctx = s->ctx;
 
                if (ctx->opaque) {
-                       php_http_buffer_free((php_http_buffer **) &ctx->opaque);
+                       php_http_buffer_free((php_http_buffer_t **) &ctx->opaque);
                }
                inflateEnd(ctx);
                pefree(ctx, (s->flags & PHP_HTTP_ENCODING_STREAM_PERSISTENT));
index 59442fc..d12efb0 100644 (file)
 
 #include "php_http.h"
 
+#include <main/SAPI.h>
+#include <ext/date/php_date.h>
+#include <ext/standard/php_string.h>
+
 PHP_RINIT_FUNCTION(http_env)
 {
        PHP_HTTP_G->env.response.last_modified = 0;
@@ -338,7 +342,7 @@ static void grab_headers(void *data, void *arg TSRMLS_DC)
 PHP_HTTP_API STATUS php_http_env_get_response_headers(HashTable *headers_ht TSRMLS_DC)
 {
        STATUS status;
-       php_http_buffer headers;
+       php_http_buffer_t headers;
 
        php_http_buffer_init(&headers);
        zend_llist_apply_with_argument(&SG(sapi_headers).headers, grab_headers, &headers TSRMLS_CC);
@@ -770,7 +774,7 @@ PHP_HTTP_API void php_http_env_set_response_body(zval *container, php_http_messa
 }
 
 struct output_ctx {
-       php_http_buffer *buf;
+       php_http_buffer_t *buf;
        zval *container;
 };
 
@@ -959,7 +963,7 @@ PHP_HTTP_API STATUS php_http_env_send_response(zval *container TSRMLS_DC)
                                /* send multipart/byte-ranges message */
                                HashPosition pos;
                                zval **chunk, *zct;
-                               php_http_buffer preface;
+                               php_http_buffer_t preface;
                                int free_ct = 0;
                                char *content_type = "application/octet-stream";
                                char boundary[32], *ct_header_str = "Content-Type: multipart/byteranges; boundary=                                ";
index 1f11785..b80cc9d 100644 (file)
@@ -1,5 +1,9 @@
 #include "php_http.h"
 
+#ifdef PHP_HTTP_HAVE_HASH
+#      include "php_hash.h"
+#endif
+
 #include <ext/standard/crc32.h>
 #include <ext/standard/sha1.h>
 #include <ext/standard/md5.h>
index 9c55263..da657ac 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "php_http.h"
 
+#include <Zend/zend_exceptions.h>
 
 #ifndef PHP_HTTP_DBG_EXCEPTIONS
 #      define PHP_HTTP_DBG_EXCEPTIONS 0
index 95b3cbf..5303f06 100644 (file)
@@ -63,7 +63,7 @@ PHP_MINIT_FUNCTION(http_filter)
        }
 
 typedef struct _http_chunked_decode_filter_buffer_t {
-       php_http_buffer buffer;
+       php_http_buffer_t       buffer;
        ulong   hexlen;
 } PHP_HTTP_FILTER_BUFFER(chunked_decode);
 
@@ -223,7 +223,7 @@ static PHP_HTTP_FILTER_FUNCTION(chunked_encode)
        
        /* new data available? */
        if (buckets_in->head) {
-               php_http_buffer buf;
+               php_http_buffer_t buf;
                out_avail = 1;
                
                php_http_buffer_init(&buf);
index a70d853..07bcab5 100644 (file)
@@ -82,15 +82,16 @@ PHP_HTTP_API void php_http_header_parser_free(php_http_header_parser_t **parser)
        }
 }
 
-PHP_HTTP_API STATUS php_http_header_parser_parse(php_http_header_parser_t *parser, php_http_buffer *buffer, unsigned flags, HashTable *headers, php_http_info_callback_t callback_func, void *callback_arg)
+PHP_HTTP_API 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)
 {
        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"};
-               fprintf(stderr, "#HP: %s (%d) %zu\n",
-                               state[php_http_header_parser_state_is(parser)], zend_hash_num_elements(headers), buffer->used);
+               fprintf(stderr, "#HP-%p: %s (%d) %.*s…\n", parser,
+                               php_http_header_parser_state_is(parser)<0?"FAILURE":state[php_http_header_parser_state_is(parser)],
+                                               zend_hash_num_elements(headers), MIN(16,buffer->used), buffer->data);
 #endif
                switch (php_http_header_parser_state_pop(parser)) {
                        case PHP_HTTP_HEADER_PARSER_STATE_FAILURE:
@@ -135,32 +136,6 @@ PHP_HTTP_API STATUS php_http_header_parser_parse(php_http_header_parser_t *parse
                                        return php_http_header_parser_state_push(parser, 1, PHP_HTTP_HEADER_PARSER_STATE_FAILURE);
                                }
                                break;
-                               /*
-                               if (colon && (!eol_str || colon < eol_str)) {
-                                       parser->_key.str = estrndup(buffer->data, parser->_key.len = colon - buffer->data);
-                                       while (PHP_HTTP_IS_CTYPE(space, *++colon));
-                                       php_http_buffer_cut(buffer, 0, colon - buffer->data);
-                                       php_http_header_parser_state_push(parser, 1, PHP_HTTP_HEADER_PARSER_STATE_VALUE);
-                               } else if (eol_str) {
-                                       if (eol_str == buffer->data) {
-                                               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)) {
-                                               if (callback_func) {
-                                                       callback_func(callback_arg, &headers, &parser->info TSRMLS_CC);
-                                               }
-                                               php_http_info_dtor(&parser->info);
-                                               php_http_buffer_cut(buffer, 0, eol_str + eol_len - buffer->data);
-                                               php_http_header_parser_state_push(parser, 1, PHP_HTTP_HEADER_PARSER_STATE_HEADER_DONE);
-                                       } else {
-                                               return PHP_HTTP_HEADER_PARSER_STATE_FAILURE;
-                                       }
-                               } else {
-                                       php_http_header_parser_state_push(parser, 1, PHP_HTTP_HEADER_PARSER_STATE_KEY);
-                                       return PHP_HTTP_HEADER_PARSER_STATE_KEY;
-                               }
-                               break;
-                               */
                        }
 
                        case PHP_HTTP_HEADER_PARSER_STATE_VALUE: {
index 9d24be1..9d6ebcc 100644 (file)
@@ -34,6 +34,6 @@ PHP_HTTP_API php_http_header_parser_state_t php_http_header_parser_state_is(php_
 PHP_HTTP_API php_http_header_parser_state_t php_http_header_parser_state_pop(php_http_header_parser_t *parser);
 PHP_HTTP_API void php_http_header_parser_dtor(php_http_header_parser_t *parser);
 PHP_HTTP_API void php_http_header_parser_free(php_http_header_parser_t **parser);
-PHP_HTTP_API STATUS php_http_header_parser_parse(php_http_header_parser_t *parser, php_http_buffer *buffer, unsigned flags, HashTable *headers, php_http_info_callback_t callback_func, void *callback_arg);
+PHP_HTTP_API 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);
 
 #endif /* PHP_HTTP_HEADER_PARSER_H */
index b5a700e..0c4cbfa 100644 (file)
@@ -17,7 +17,7 @@
 PHP_HTTP_API STATUS php_http_headers_parse(const char *header, size_t length, HashTable *headers, php_http_info_callback_t callback_func, void **callback_data TSRMLS_DC)
 {
        php_http_header_parser_t ctx;
-       php_http_buffer buf;
+       php_http_buffer_t buf;
        
        php_http_buffer_from_string_ex(&buf, header, length);
        php_http_header_parser_init(&ctx TSRMLS_CC);
index 5f9220e..c1c82e9 100644 (file)
@@ -14,7 +14,9 @@
 
 #include "php_http.h"
 
-/* API */
+#include <main/SAPI.h>
+#include <ext/spl/spl_iterators.h>
+#include <Zend/zend_interfaces.h>
 
 PHP_HTTP_API zend_bool php_http_message_info_callback(php_http_message_t **message, HashTable **headers, php_http_info_t *info TSRMLS_DC)
 {
@@ -127,7 +129,7 @@ PHP_HTTP_API php_http_message_t *php_http_message_init_env(php_http_message_t *m
 PHP_HTTP_API php_http_message_t *php_http_message_parse(php_http_message_t *msg, const char *str, size_t len TSRMLS_DC)
 {
        php_http_message_parser_t p;
-       php_http_buffer buf;
+       php_http_buffer_t buf;
 
        if (!msg) {
                msg = php_http_message_init(NULL, 0 TSRMLS_CC);
@@ -151,7 +153,7 @@ PHP_HTTP_API zval *php_http_message_header(php_http_message_t *msg, char *key_st
                if (join && Z_TYPE_PP(header) == IS_ARRAY) {
                        zval *header_str, **val;
                        HashPosition pos;
-                       php_http_buffer str;
+                       php_http_buffer_t str;
 
                        php_http_buffer_init(&str);
                        MAKE_STD_ZVAL(header_str);
@@ -217,7 +219,7 @@ PHP_HTTP_API void php_http_message_set_info(php_http_message_t *message, php_htt
        }
 }
 
-static inline void message_headers(php_http_message_t *msg, php_http_buffer *str)
+static inline void message_headers(php_http_message_t *msg, php_http_buffer_t *str)
 {
        php_http_array_hashkey_t key = php_http_array_hashkey_init(0);
        HashPosition pos1;
@@ -287,7 +289,7 @@ static inline void message_headers(php_http_message_t *msg, php_http_buffer *str
 
 PHP_HTTP_API void php_http_message_to_callback(php_http_message_t *msg, php_http_pass_callback_t cb, void *cb_arg)
 {
-       php_http_buffer str;
+       php_http_buffer_t str;
        TSRMLS_FETCH_FROM_CTX(msg->ts);
 
        php_http_buffer_init_ex(&str, 0x1000, 0);
@@ -304,7 +306,7 @@ PHP_HTTP_API void php_http_message_to_callback(php_http_message_t *msg, php_http
 
 PHP_HTTP_API void php_http_message_to_string(php_http_message_t *msg, char **string, size_t *length)
 {
-       php_http_buffer str;
+       php_http_buffer_t str;
        char *data;
 
        php_http_buffer_init_ex(&str, 0x1000, 0);
@@ -327,7 +329,7 @@ PHP_HTTP_API void php_http_message_serialize(php_http_message_t *message, char *
 {
        char *buf;
        size_t len;
-       php_http_buffer str;
+       php_http_buffer_t str;
 
        php_http_buffer_init(&str);
 
@@ -601,9 +603,6 @@ PHP_HTTP_API void php_http_message_free(php_http_message_t **message)
        }
 }
 
-
-/* PHP */
-
 #define PHP_HTTP_BEGIN_ARGS(method, req_args)  PHP_HTTP_BEGIN_ARGS_EX(HttpMessage, method, 0, req_args)
 #define PHP_HTTP_EMPTY_ARGS(method)                            PHP_HTTP_EMPTY_ARGS_EX(HttpMessage, method, 0)
 #define PHP_HTTP_MESSAGE_ME(method, visibility)        PHP_ME(HttpMessage, method, PHP_HTTP_ARGS(HttpMessage, method), visibility)
index cd85eea..7d84fc2 100644 (file)
@@ -35,6 +35,6 @@ PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_state_is(ph
 PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_state_pop(php_http_message_parser_t *parser);
 PHP_HTTP_API void php_http_message_parser_dtor(php_http_message_parser_t *parser);
 PHP_HTTP_API void php_http_message_parser_free(php_http_message_parser_t **parser);
-PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_parse(php_http_message_parser_t *parser, php_http_buffer *buffer, unsigned flags, php_http_message_t **message);
+PHP_HTTP_API php_http_message_parser_state_t php_http_message_parser_parse(php_http_message_parser_t *parser, php_http_buffer_t *buffer, unsigned flags, php_http_message_t **message);
 
 #endif
index 8d52382..c52f83f 100644 (file)
 
 #include "php_http.h"
 
+#include <ext/standard/php_lcg.h>
+#include <ext/standard/php_string.h>
+#include <Zend/zend_exceptions.h>
+
 /* SLEEP */
 
 PHP_HTTP_API void php_http_sleep(double s)
@@ -208,7 +212,7 @@ void php_http_error(long type TSRMLS_DC, long code, const char *format, ...)
                        char *message;
                        zend_class_entry *ce;
 
-                       if (EG(exception_class) && instanceof_function(EG(exception_class), php_http_exception_class_entry)) {
+                       if (0&& EG(exception_class) && instanceof_function(EG(exception_class), php_http_exception_class_entry)) {
                                ce = EG(exception_class);
                        } else {
                                ce = php_http_exception_get_for_code(code);
index 2b3d6e9..1cac48b 100644 (file)
@@ -373,7 +373,7 @@ extern int php_http_array_apply_merge_func(void *pDest TSRMLS_DC, int num_args,
 /* PASS CALLBACK */
 
 typedef size_t (*php_http_pass_callback_t)(void *cb_arg, const char *str, size_t len);
-typedef size_t (*php_http_pass_php_http_buffer_callback_t)(void *cb_arg, php_http_buffer *str);
+typedef size_t (*php_http_pass_php_http_buffer_callback_t)(void *cb_arg, php_http_buffer_t *str);
 
 typedef struct php_http_pass_callback_arg {
        size_t (*cb_zts)(void *cb_arg, const char *str, size_t len TSRMLS_DC);
index 43b4236..b8f50f1 100644 (file)
@@ -14,6 +14,8 @@
 
 #include "php_http.h"
 
+#include <ext/standard/php_string.h>
+
 #ifndef PHP_HTTP_DBG_NEG
 #      define PHP_HTTP_DBG_NEG 0
 #endif
index ffa5052..8b9e2c6 100644 (file)
 
 #include "php_http.h"
 
-/** API **/
+#include <main/php_variables.h>
+#include <ext/spl/spl_array.h>
+#include <Zend/zend_interfaces.h>
+
+#ifdef PHP_HTTP_HAVE_ICONV
+#      undef PHP_ATOM_INC
+#      include <ext/iconv/php_iconv.h>
+#endif
 
 static inline int php_http_querystring_modify_array_ex(zval *qarray, int key_type, char *key, int keylen, ulong idx, zval *params_entry TSRMLS_DC);
 static inline int php_http_querystring_modify_array(zval *qarray, zval *params TSRMLS_DC);
@@ -188,8 +195,6 @@ static inline int php_http_querystring_modify_array_ex(zval *qarray, int key_typ
        return 1;
 }
 
-/** PHP **/
-
 #define PHP_HTTP_BEGIN_ARGS(method, req_args)                  PHP_HTTP_BEGIN_ARGS_EX(HttpQueryString, method, 0, req_args)
 #define PHP_HTTP_EMPTY_ARGS(method)                                            PHP_HTTP_EMPTY_ARGS_EX(HttpQueryString, method, 0)
 #define PHP_HTTP_QUERYSTRING_ME(method, visibility)            PHP_ME(HttpQueryString, method, PHP_HTTP_ARGS(HttpQueryString, method), visibility)
index 1df601f..d6d9358 100644 (file)
 
 #include "php_http.h"
 
+#include <Zend/zend_interfaces.h>
+
+#if defined(ZTS) && defined(PHP_HTTP_HAVE_SSL)
+#      ifdef PHP_WIN32
+#              define PHP_HTTP_NEED_OPENSSL_TSL
+#              include <openssl/crypto.h>
+#      else /* !PHP_WIN32 */
+#              if defined(PHP_HTTP_HAVE_OPENSSL)
+#                      define PHP_HTTP_NEED_OPENSSL_TSL
+#                      include <openssl/crypto.h>
+#              elif defined(PHP_HTTP_HAVE_GNUTLS)
+#                      define PHP_HTTP_NEED_GNUTLS_TSL
+#                      include <gcrypt.h>
+#              else
+#                      warning \
+                               "libcurl was compiled with SSL support, but configure could not determine which" \
+                               "library was used; thus no SSL crypto locking callbacks will be set, which may " \
+                               "cause random crashes on SSL requests"
+#              endif /* PHP_HTTP_HAVE_OPENSSL || PHP_HTTP_HAVE_GNUTLS */
+#      endif /* PHP_WIN32 */
+#endif /* ZTS && PHP_HTTP_HAVE_SSL */
+
+
 #ifdef PHP_HTTP_NEED_OPENSSL_TSL
 static MUTEX_T *php_http_openssl_tsl = NULL;
 
@@ -623,7 +646,7 @@ PHP_HTTP_API STATUS php_http_request_prepare(php_http_request_t *request, HashTa
        else if ((zoption = php_http_request_option(request, options, ZEND_STRS("range"), IS_ARRAY)) && zend_hash_num_elements(Z_ARRVAL_P(zoption))) {
                HashPosition pos1, pos2;
                zval **rr, **rb, **re;
-               php_http_buffer rs;
+               php_http_buffer_t rs;
                
                php_http_buffer_init(&rs);
                FOREACH_VAL(pos1, zoption, rr) {
@@ -670,7 +693,7 @@ PHP_HTTP_API STATUS php_http_request_prepare(php_http_request_t *request, HashTa
                php_http_array_hashkey_t header_key = php_http_array_hashkey_init(0);
                zval **header_val;
                HashPosition pos;
-               php_http_buffer header;
+               php_http_buffer_t header;
                
                php_http_buffer_init(&header);
                FOREACH_KEYVAL(pos, zoption, header_key, header_val) {
@@ -694,7 +717,7 @@ PHP_HTTP_API STATUS php_http_request_prepare(php_http_request_t *request, HashTa
        /* etag */
        if ((zoption = php_http_request_option(request, options, ZEND_STRS("etag"), IS_STRING)) && Z_STRLEN_P(zoption)) {
                zend_bool is_quoted = !((Z_STRVAL_P(zoption)[0] != '"') || (Z_STRVAL_P(zoption)[Z_STRLEN_P(zoption)-1] != '"'));
-               php_http_buffer header;
+               php_http_buffer_t header;
                
                php_http_buffer_init(&header);
                php_http_buffer_appendf(&header, is_quoted?"%s: %s":"%s: \"%s\"", range_req?"If-Match":"If-None-Match", Z_STRVAL_P(zoption));
@@ -2077,9 +2100,8 @@ PHP_METHOD(HttpRequest, getResponseBody)
 {
        if (SUCCESS == zend_parse_parameters_none()) {
                zval *message = zend_read_property(php_http_request_class_entry, getThis(), ZEND_STRL("responseMessage"), 0 TSRMLS_CC);
-               zval *body = zend_read_property(php_http_message_class_entry, message, ZEND_STRL("body"), 0 TSRMLS_CC);
 
-               RETURN_ZVAL(body, 1, 0);
+               RETURN_OBJVAL(((php_http_message_object_t *)zend_object_store_get_object(message TSRMLS_CC))->body, 1);
        }
        RETURN_FALSE;
 }
index 9e314ca..5432715 100644 (file)
@@ -39,11 +39,11 @@ typedef struct php_http_request {
        struct {
                php_http_message_parser_t *ctx;
                php_http_message_t *msg;
-               php_http_buffer *buf;
+               php_http_buffer_t *buf;
        } parser;
        
        struct {
-               php_http_buffer cookies;
+               php_http_buffer_t cookies;
                HashTable options;
                struct curl_slist *headers;
        } _cache;
index c1df14b..f572d3f 100644 (file)
@@ -1,6 +1,8 @@
 
 #include "php_http.h"
 
+#include <ext/spl/spl_iterators.h>
+
 static HashTable php_http_request_datashare_options;
 static php_http_request_datashare_t php_http_request_datashare_global;
 static int php_http_request_datashare_compare_handles(void *h1, void *h2);
index 298b867..b482d03 100644 (file)
@@ -14,6 +14,8 @@
 
 #include "php_http.h"
 
+#include <Zend/zend_interfaces.h>
+
 static PHP_HTTP_STRLIST(php_http_request_methods) =
        PHP_HTTP_STRLIST_ITEM("UNKNOWN")
        /* HTTP/1.1 */
index 8585d77..bfd1ff2 100644 (file)
@@ -1,6 +1,12 @@
 
 #include "php_http.h"
 
+#ifdef PHP_HTTP_HAVE_EVENT
+#      include <event.h>
+#endif
+
+#include <ext/spl/spl_iterators.h>
+#include <Zend/zend_interfaces.h>
 
 #ifndef PHP_HTTP_DEBUG_REQPOOLS
 #      define PHP_HTTP_DEBUG_REQPOOLS 0
index 8675fa6..6f09224 100644 (file)
@@ -14,6 +14,9 @@
 
 #include "php_http.h"
 
+#include <main/SAPI.h>
+#include <ext/standard/php_string.h>
+
 static inline char *localhostname(void)
 {
        char hostname[1024] = {0};
@@ -326,7 +329,7 @@ PHP_HTTP_API STATUS php_http_url_encode_hash(HashTable *hash, zend_bool override
 {
        char *arg_sep;
        size_t arg_sep_len;
-       php_http_buffer *qstr = php_http_buffer_new();
+       php_http_buffer_t *qstr = php_http_buffer_new();
 
        if (override_argsep || !(arg_sep_len = strlen(arg_sep = INI_STR("arg_separator.output")))) {
                arg_sep = PHP_HTTP_URL_ARGSEP;
@@ -348,7 +351,7 @@ PHP_HTTP_API STATUS php_http_url_encode_hash(HashTable *hash, zend_bool override
        return SUCCESS;
 }
 
-PHP_HTTP_API STATUS php_http_url_encode_hash_recursive(HashTable *ht, php_http_buffer *str, const char *arg_sep, size_t arg_sep_len, const char *prefix, size_t prefix_len TSRMLS_DC)
+PHP_HTTP_API STATUS php_http_url_encode_hash_recursive(HashTable *ht, php_http_buffer_t *str, const char *arg_sep, size_t arg_sep_len, const char *prefix, size_t prefix_len TSRMLS_DC)
 {
        php_http_array_hashkey_t key = php_http_array_hashkey_init(0);
        zval **data = NULL;
@@ -365,7 +368,7 @@ PHP_HTTP_API STATUS php_http_url_encode_hash_recursive(HashTable *ht, php_http_b
        FOREACH_HASH_KEYVAL(pos, ht, key, data) {
                char *encoded_key;
                int encoded_len;
-               php_http_buffer new_prefix;
+               php_http_buffer_t new_prefix;
                
                if (!data || !*data) {
                        php_http_buffer_dtor(str);
index bbb6177..6d1e9d7 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef PHP_HTTP_URL_H
 #define PHP_HTTP_URL_H
 
+#include <ext/standard/url.h>
+
 #define PHP_HTTP_URL_REPLACE           0x000
 #define PHP_HTTP_URL_JOIN_PATH         0x001
 #define PHP_HTTP_URL_JOIN_QUERY                0x002
@@ -38,7 +40,7 @@ PHP_HTTP_API void php_http_url(int flags, const php_url *old_url, const php_url
 PHP_HTTP_API char *php_http_url_absolute(const char *url, int flags TSRMLS_DC);
 
 PHP_HTTP_API STATUS php_http_url_encode_hash(HashTable *hash, zend_bool override_argsep, char *pre_encoded_data, size_t pre_encoded_len, char **encoded_data, size_t *encoded_len TSRMLS_DC);
-PHP_HTTP_API STATUS php_http_url_encode_hash_recursive(HashTable *ht, php_http_buffer *str, const char *arg_sep, size_t arg_sep_len, const char *prefix, size_t prefix_len TSRMLS_DC);
+PHP_HTTP_API STATUS php_http_url_encode_hash_recursive(HashTable *ht, php_http_buffer_t *str, const char *arg_sep, size_t arg_sep_len, const char *prefix, size_t prefix_len TSRMLS_DC);
 
 static inline php_url *php_http_url_from_struct(php_url *url, HashTable *ht TSRMLS_DC)
 {