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 273ef7baaef04ceabfed651ba3d2df9c8e7cb1c8..47fba6412ac76eb2736c24867e75dce222c8609d 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 c23b608f8455c14f4acf7a6801f697b971d5dbc2..42f7d13aeea07e4a9378ea6b6eaf7a5a07ff89ab 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 a300eb561fa54048b249ca525191988ca1e31cb6..07a026d3fe532de0cd44cd9c1a60b6c95106637a 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 59442fc4f35e8bc0004faf0fd0699eed1ab81893..d12efb0a4f92949b58bcb98222ccc0ba17616f49 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 1f1178517c4071c5a1dfe29aaf776521dbcd05c8..b80cc9df85ce0422d43e589e4a2d7ae8059b9468 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 9c5526376a56836aa425d9aab9cc5aa4edb58d68..da657ac9b8d357dbc419cd418e1de338a540dbf2 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 95b3cbf13f5096ed0856782b5107a3168a3e570b..5303f067cf87d41964687a8114457d1154ddbace 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 a70d853f6a061e6c90dac877ef4bb932bdf47e47..07bcab5f930019e54c49bd7eb42ad3d4e93c5e34 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 9d24be1cd543d106853f6f232167e11fcec341a0..9d6ebccfbfb05f248ed7e93e62bfd6a4b3b0f248 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 b5a700e1a8668b3e0fccdbf994f60380af6a33b7..0c4cbfa354fe6c5396ef3654fb5a396e823457b8 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 5f9220edd2ab90da51d4687e0a6c0e9050fe5497..c1c82e98e453bce6604d131adc76d32ac9a4ba5a 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 cd85eea6d59c327b2a173089d319e9db6ce21852..7d84fc2ef1deef6cc82b5d3c42bd345b266d56ea 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 8d52382f6105a444888c76d4baf93fa1472fe0da..c52f83f91fddc6f840e3b52964830a9a55294a36 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 2b3d6e96226d244d2fb99a76d8e670eb4936c6e3..1cac48b266d0f543ee51fd43fefb18881952d5a7 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 43b4236916c543cece93a13bd0babfa15e128fce..b8f50f1105721a1de6c60d79424b77d3833d8c33 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 ffa50522e0f4ce07838d5ee4d82e7c374f241622..8b9e2c6e6377ebacb08eebc4c280d50d00ca19da 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 1df601fb6c4817012342967440d116f0b51f0138..d6d93587eaff4879b3e9857b9c6bd359d02c796e 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 9e314caec9b87c8866900d617cab5bb7d6ff8bc1..543271563b215c41fa4cbaaed17add2949c2839d 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 c1df14bd41f7427b3a8d281a1a2a1499522447b0..f572d3fbbe82621e7a1246e58038ed437eacac87 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 298b867ae3415bb381b1d47a0e5064e20a3d6e63..b482d03ec89ffa0f966c2ae2f2b72f67988aa4f0 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 8585d775171a91cfa6f853e272e666ce9b5477a2..bfd1ff2066363e2e2a9f5a0eacc8f1923e93508e 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 8675fa6c5e3815a711f39e9b8eb9e59543d184e4..6f0922482db3a6dbffcbf4e1ebca5a098f591720 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 bbb6177617e957acb3762570bdd7c893e011e381..6d1e9d716629a17cad9aeb73da1b3318f0c957ab 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)
 {