From: Michael Wallner Date: Thu, 9 Sep 2010 09:10:32 +0000 (+0000) Subject: cleanups & includes X-Git-Tag: DEV_2-before-client~137 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=commitdiff_plain;h=c5c580f24e24e8032a0554a2e39e38c496144bc2 cleanups & includes --- diff --git a/php_http.c b/php_http.c index 273ef7b..47fba64 100644 --- a/php_http.c +++ b/php_http.c @@ -14,6 +14,12 @@ #include "php_http.h" +#include +#include +#ifdef PHP_HTTP_HAVE_EVENT +# include +#endif + #include
#include #include @@ -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(); diff --git a/php_http_cookie.c b/php_http_cookie.c index c23b608..42f7d13 100644 --- a/php_http_cookie.c +++ b/php_http_cookie.c @@ -14,6 +14,8 @@ #include "php_http.h" +#include + 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; diff --git a/php_http_encoding.c b/php_http_encoding.c index a300eb5..07a026d 100644 --- a/php_http_encoding.c +++ b/php_http_encoding.c @@ -14,6 +14,8 @@ #include "php_http.h" +#include + 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)); diff --git a/php_http_env.c b/php_http_env.c index 59442fc..d12efb0 100644 --- a/php_http_env.c +++ b/php_http_env.c @@ -14,6 +14,10 @@ #include "php_http.h" +#include
+#include +#include + 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= "; diff --git a/php_http_etag.c b/php_http_etag.c index 1f11785..b80cc9d 100644 --- a/php_http_etag.c +++ b/php_http_etag.c @@ -1,5 +1,9 @@ #include "php_http.h" +#ifdef PHP_HTTP_HAVE_HASH +# include "php_hash.h" +#endif + #include #include #include diff --git a/php_http_exception.c b/php_http_exception.c index 9c55263..da657ac 100644 --- a/php_http_exception.c +++ b/php_http_exception.c @@ -14,6 +14,7 @@ #include "php_http.h" +#include #ifndef PHP_HTTP_DBG_EXCEPTIONS # define PHP_HTTP_DBG_EXCEPTIONS 0 diff --git a/php_http_filter.c b/php_http_filter.c index 95b3cbf..5303f06 100644 --- a/php_http_filter.c +++ b/php_http_filter.c @@ -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); diff --git a/php_http_header_parser.c b/php_http_header_parser.c index a70d853..07bcab5 100644 --- a/php_http_header_parser.c +++ b/php_http_header_parser.c @@ -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: { diff --git a/php_http_header_parser.h b/php_http_header_parser.h index 9d24be1..9d6ebcc 100644 --- a/php_http_header_parser.h +++ b/php_http_header_parser.h @@ -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 */ diff --git a/php_http_headers.c b/php_http_headers.c index b5a700e..0c4cbfa 100644 --- a/php_http_headers.c +++ b/php_http_headers.c @@ -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); diff --git a/php_http_message.c b/php_http_message.c index 5f9220e..c1c82e9 100644 --- a/php_http_message.c +++ b/php_http_message.c @@ -14,7 +14,9 @@ #include "php_http.h" -/* API */ +#include
+#include +#include 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) diff --git a/php_http_message_parser.h b/php_http_message_parser.h index cd85eea..7d84fc2 100644 --- a/php_http_message_parser.h +++ b/php_http_message_parser.h @@ -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 diff --git a/php_http_misc.c b/php_http_misc.c index 8d52382..c52f83f 100644 --- a/php_http_misc.c +++ b/php_http_misc.c @@ -14,6 +14,10 @@ #include "php_http.h" +#include +#include +#include + /* 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); diff --git a/php_http_misc.h b/php_http_misc.h index 2b3d6e9..1cac48b 100644 --- a/php_http_misc.h +++ b/php_http_misc.h @@ -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); diff --git a/php_http_negotiate.c b/php_http_negotiate.c index 43b4236..b8f50f1 100644 --- a/php_http_negotiate.c +++ b/php_http_negotiate.c @@ -14,6 +14,8 @@ #include "php_http.h" +#include + #ifndef PHP_HTTP_DBG_NEG # define PHP_HTTP_DBG_NEG 0 #endif diff --git a/php_http_querystring.c b/php_http_querystring.c index ffa5052..8b9e2c6 100644 --- a/php_http_querystring.c +++ b/php_http_querystring.c @@ -14,7 +14,14 @@ #include "php_http.h" -/** API **/ +#include
+#include +#include + +#ifdef PHP_HTTP_HAVE_ICONV +# undef PHP_ATOM_INC +# include +#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) diff --git a/php_http_request.c b/php_http_request.c index 1df601f..d6d9358 100644 --- a/php_http_request.c +++ b/php_http_request.c @@ -14,6 +14,29 @@ #include "php_http.h" +#include + +#if defined(ZTS) && defined(PHP_HTTP_HAVE_SSL) +# ifdef PHP_WIN32 +# define PHP_HTTP_NEED_OPENSSL_TSL +# include +# else /* !PHP_WIN32 */ +# if defined(PHP_HTTP_HAVE_OPENSSL) +# define PHP_HTTP_NEED_OPENSSL_TSL +# include +# elif defined(PHP_HTTP_HAVE_GNUTLS) +# define PHP_HTTP_NEED_GNUTLS_TSL +# include +# 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; } diff --git a/php_http_request.h b/php_http_request.h index 9e314ca..5432715 100644 --- a/php_http_request.h +++ b/php_http_request.h @@ -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; diff --git a/php_http_request_datashare.c b/php_http_request_datashare.c index c1df14b..f572d3f 100644 --- a/php_http_request_datashare.c +++ b/php_http_request_datashare.c @@ -1,6 +1,8 @@ #include "php_http.h" +#include + 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); diff --git a/php_http_request_method.c b/php_http_request_method.c index 298b867..b482d03 100644 --- a/php_http_request_method.c +++ b/php_http_request_method.c @@ -14,6 +14,8 @@ #include "php_http.h" +#include + static PHP_HTTP_STRLIST(php_http_request_methods) = PHP_HTTP_STRLIST_ITEM("UNKNOWN") /* HTTP/1.1 */ diff --git a/php_http_request_pool.c b/php_http_request_pool.c index 8585d77..bfd1ff2 100644 --- a/php_http_request_pool.c +++ b/php_http_request_pool.c @@ -1,6 +1,12 @@ #include "php_http.h" +#ifdef PHP_HTTP_HAVE_EVENT +# include +#endif + +#include +#include #ifndef PHP_HTTP_DEBUG_REQPOOLS # define PHP_HTTP_DEBUG_REQPOOLS 0 diff --git a/php_http_url.c b/php_http_url.c index 8675fa6..6f09224 100644 --- a/php_http_url.c +++ b/php_http_url.c @@ -14,6 +14,9 @@ #include "php_http.h" +#include
+#include + 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); diff --git a/php_http_url.h b/php_http_url.h index bbb6177..6d1e9d7 100644 --- a/php_http_url.h +++ b/php_http_url.h @@ -15,6 +15,8 @@ #ifndef PHP_HTTP_URL_H #define PHP_HTTP_URL_H +#include + #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) {