add http\Env\Url
authorMichael Wallner <mike@php.net>
Fri, 4 Dec 2015 13:00:34 +0000 (14:00 +0100)
committerMichael Wallner <mike@php.net>
Fri, 4 Dec 2015 13:03:51 +0000 (14:03 +0100)
remove http\Url::FROM_ENV from default flags
add class_entry accessors

35 files changed:
src/php_http_client.c
src/php_http_client.h
src/php_http_client_request.c
src/php_http_client_request.h
src/php_http_client_response.c
src/php_http_client_response.h
src/php_http_cookie.c
src/php_http_cookie.h
src/php_http_encoding.c
src/php_http_encoding.h
src/php_http_env.c
src/php_http_env.h
src/php_http_env_request.c
src/php_http_env_request.h
src/php_http_env_response.c
src/php_http_env_response.h
src/php_http_exception.c
src/php_http_exception.h
src/php_http_header.c
src/php_http_header.h
src/php_http_header_parser.c
src/php_http_header_parser.h
src/php_http_message.c
src/php_http_message.h
src/php_http_message_body.c
src/php_http_message_body.h
src/php_http_message_parser.c
src/php_http_message_parser.h
src/php_http_params.c
src/php_http_params.h
src/php_http_querystring.c
src/php_http_querystring.h
src/php_http_url.c
src/php_http_url.h
tests/url001.phpt

index 5d78803154676f52248647338ffb463c88ce82ac..5de1eac6dd2311a22bb5b175292f2186839220cf 100644 (file)
@@ -61,6 +61,12 @@ void php_http_client_driver_list(HashTable *ht)
        zend_hash_apply_with_argument(&php_http_client_drivers, apply_driver_list, ht);
 }
 
+static zend_class_entry *php_http_client_class_entry;
+zend_class_entry *php_http_client_get_class_entry(void)
+{
+       return php_http_client_class_entry;
+}
+
 void php_http_client_options_set_subr(zval *instance, char *key, size_t len, zval *opts, int overwrite)
 {
        if (overwrite || (opts && zend_hash_num_elements(Z_ARRVAL_P(opts)))) {
@@ -318,7 +324,6 @@ ZEND_RESULT_CODE php_http_client_getopt(php_http_client_t *h, php_http_client_ge
        return FAILURE;
 }
 
-zend_class_entry *php_http_client_class_entry;
 static zend_object_handlers php_http_client_object_handlers;
 
 void php_http_client_object_free(zend_object *object)
@@ -357,7 +362,7 @@ static void handle_history(zval *zclient, php_http_message_t *request, php_http_
        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);
-       php_http_message_object_t *obj = php_http_message_object_new_ex(php_http_message_class_entry, zipped);
+       php_http_message_object_t *obj = php_http_message_object_new_ex(php_http_message_get_class_entry(), zipped);
 
        ZVAL_OBJ(&new_hist, &obj->zo);
 
@@ -394,7 +399,7 @@ static ZEND_RESULT_CODE handle_response(void *arg, php_http_client_t *client, ph
                php_http_message_free(&msg->parent);
                *response = NULL;
 
-               msg_obj = php_http_message_object_new_ex(php_http_client_response_class_entry, msg);
+               msg_obj = php_http_message_object_new_ex(php_http_get_client_response_class_entry(), msg);
                ZVAL_OBJ(&zresponse, &msg_obj->zo);
                ZVAL_OBJECT(&zrequest, &((php_http_message_object_t *) e->opaque)->zo, 1);
 
@@ -403,7 +408,7 @@ static ZEND_RESULT_CODE handle_response(void *arg, php_http_client_t *client, ph
                object_init(&info);
                info_ht = HASH_OF(&info);
                php_http_client_getopt(client, PHP_HTTP_CLIENT_OPT_TRANSFER_INFO, e->request, &info_ht);
-               zend_update_property(php_http_client_response_class_entry, &zresponse, ZEND_STRL("transferInfo"), &info);
+               zend_update_property(php_http_get_client_response_class_entry(), &zresponse, ZEND_STRL("transferInfo"), &info);
                zval_ptr_dtor(&info);
 
                Z_ADDREF(zresponse);
@@ -599,7 +604,7 @@ static PHP_METHOD(HttpClient, enqueue)
        php_http_message_object_t *msg_obj;
        php_http_client_enqueue_t q;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O|f", &request, php_http_client_request_class_entry, &fci, &fcc), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O|f", &request, php_http_get_client_request_class_entry(), &fci, &fcc), invalid_arg, return);
 
        obj = PHP_HTTP_OBJ(NULL, getThis());
        msg_obj = PHP_HTTP_OBJ(NULL, request);
@@ -642,7 +647,7 @@ static PHP_METHOD(HttpClient, dequeue)
        php_http_client_object_t *obj;
        php_http_message_object_t *msg_obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &request, php_http_client_request_class_entry), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &request, php_http_get_client_request_class_entry()), invalid_arg, return);
 
        obj = PHP_HTTP_OBJ(NULL, getThis());
        msg_obj = PHP_HTTP_OBJ(NULL, request);
@@ -670,7 +675,7 @@ static PHP_METHOD(HttpClient, requeue)
        php_http_message_object_t *msg_obj;
        php_http_client_enqueue_t q;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O|f", &request, php_http_client_request_class_entry, &fci, &fcc), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O|f", &request, php_http_get_client_request_class_entry(), &fci, &fcc), invalid_arg, return);
 
        obj = PHP_HTTP_OBJ(NULL, getThis());
        msg_obj = PHP_HTTP_OBJ(NULL, request);
@@ -724,7 +729,7 @@ static PHP_METHOD(HttpClient, getResponse)
        zval *zrequest = NULL;
        php_http_client_object_t *obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|O", &zrequest, php_http_client_request_class_entry), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|O", &zrequest, php_http_get_client_request_class_entry()), invalid_arg, return);
 
        obj = PHP_HTTP_OBJ(NULL, getThis());
 
@@ -892,7 +897,7 @@ static PHP_METHOD(HttpClient, notify)
        php_http_client_object_t *client_obj;
        struct notify_arg arg = {NULL};
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|O!o!", &request, php_http_client_request_class_entry, &zprogress), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|O!o!", &request, php_http_get_client_request_class_entry(), &zprogress), invalid_arg, return);
 
        client_obj = PHP_HTTP_OBJ(NULL, getThis());
        observers = zend_read_property(php_http_client_class_entry, getThis(), ZEND_STRL("observers"), 0, &observers_tmp);
@@ -1010,7 +1015,7 @@ static PHP_METHOD(HttpClient, getProgressInfo)
        php_http_message_object_t *req_obj;
        php_http_client_progress_state_t *progress;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &request, php_http_client_request_class_entry), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &request, php_http_get_client_request_class_entry()), invalid_arg, return);
 
        obj = PHP_HTTP_OBJ(NULL, getThis());
        req_obj = PHP_HTTP_OBJ(NULL, request);
@@ -1037,7 +1042,7 @@ static PHP_METHOD(HttpClient, getTransferInfo)
        php_http_client_object_t *obj;
        php_http_message_object_t *req_obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &request, php_http_client_request_class_entry), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &request, php_http_get_client_request_class_entry()), invalid_arg, return);
 
        obj = PHP_HTTP_OBJ(NULL, getThis());
        req_obj = PHP_HTTP_OBJ(NULL, request);
index 792581a4da017906ffa05b5e550069b39a0b2157..6aa8abf282f6da9f0afe1a6d519ba22eb31afb4b 100644 (file)
@@ -111,7 +111,7 @@ typedef struct php_http_client {
        zend_llist responses;
 } php_http_client_t;
 
-PHP_HTTP_API zend_class_entry *php_http_client_class_entry;
+PHP_HTTP_API zend_class_entry *php_http_client_get_class_entry();
 
 typedef struct php_http_client_object {
        php_http_client_t *client;
index 05d4a81f5d75b0a00cf4d2484b328fa3bfa3c841..f64c357b6f01bef74ce8e596e234493362f52f75 100644 (file)
 
 #include "php_http_api.h"
 
+static zend_class_entry *php_http_client_request_class_entry;
+zend_class_entry *php_http_get_client_request_class_entry(void)
+{
+       return php_http_client_request_class_entry;
+}
+
 void php_http_client_options_set_subr(zval *this_ptr, char *key, size_t len, zval *opts, int overwrite);
 void php_http_client_options_set(zval *this_ptr, zval *opts);
 void php_http_client_options_get_subr(zval *this_ptr, char *key, size_t len, zval *return_value);
@@ -36,7 +42,7 @@ static PHP_METHOD(HttpClientRequest, __construct)
        zval *zheaders = NULL, *zbody = NULL, *zurl = NULL;
        php_http_message_object_t *obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|s!z!a!O!", &meth_str, &meth_len, &zurl, &zheaders, &zbody, php_http_message_body_class_entry), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|s!z!a!O!", &meth_str, &meth_len, &zurl, &zheaders, &zbody, php_http_get_message_body_class_entry()), invalid_arg, return);
 
        obj = PHP_HTTP_OBJ(NULL, getThis());
 
@@ -276,14 +282,12 @@ static zend_function_entry php_http_client_request_methods[] = {
        EMPTY_FUNCTION_ENTRY
 };
 
-zend_class_entry *php_http_client_request_class_entry;
-
 PHP_MINIT_FUNCTION(http_client_request)
 {
        zend_class_entry ce = {0};
 
        INIT_NS_CLASS_ENTRY(ce, "http\\Client", "Request", php_http_client_request_methods);
-       php_http_client_request_class_entry = zend_register_internal_class_ex(&ce, php_http_message_class_entry);
+       php_http_client_request_class_entry = zend_register_internal_class_ex(&ce, php_http_message_get_class_entry());
 
        zend_declare_property_null(php_http_client_request_class_entry, ZEND_STRL("options"), ZEND_ACC_PROTECTED);
 
index 474114babf1e918213af4566ef0a7e3eb9c139c6..aee4da514cd95439d3c3d1de3149af1b32837b1e 100644 (file)
@@ -13,7 +13,7 @@
 #ifndef PHP_HTTP_CLIENT_REQUEST_H
 #define PHP_HTTP_CLIENT_REQUEST_H
 
-PHP_HTTP_API zend_class_entry *php_http_client_request_class_entry;
+PHP_HTTP_API zend_class_entry *php_http_get_client_request_class_entry(void);
 PHP_MINIT_FUNCTION(http_client_request);
 
 #endif /* PHP_HTTP_CLIENT_REQUEST_H */
index b1377fe64c7b3d49aed4604c992501de9b4026c3..5acddae163ab782a63f1312808b70c1beffe363d 100644 (file)
 
 #include "php_http_api.h"
 
+static zend_class_entry *php_http_client_response_class_entry;
+zend_class_entry *php_http_get_client_response_class_entry(void)
+{
+       return php_http_client_response_class_entry;
+}
+
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpClientResponse_getCookies, 0, 0, 0)
        ZEND_ARG_INFO(0, flags)
        ZEND_ARG_INFO(0, allowed_extras)
@@ -57,7 +63,7 @@ static PHP_METHOD(HttpClientResponse, getCookies)
                                if ((list = php_http_cookie_list_parse(NULL, zs->val, zs->len, flags, allowed_extras))) {
                                        zval cookie;
 
-                                       ZVAL_OBJ(&cookie, &php_http_cookie_object_new_ex(php_http_cookie_class_entry, list)->zo);
+                                       ZVAL_OBJ(&cookie, &php_http_cookie_object_new_ex(php_http_cookie_get_class_entry(), list)->zo);
                                        add_next_index_zval(return_value, &cookie);
                                }
                                zend_string_release(zs);
@@ -69,7 +75,7 @@ static PHP_METHOD(HttpClientResponse, getCookies)
                        if ((list = php_http_cookie_list_parse(NULL, zs->val, zs->len, flags, allowed_extras))) {
                                zval cookie;
 
-                               ZVAL_OBJ(&cookie, &php_http_cookie_object_new_ex(php_http_cookie_class_entry, list)->zo);
+                               ZVAL_OBJ(&cookie, &php_http_cookie_object_new_ex(php_http_cookie_get_class_entry(), list)->zo);
                                add_next_index_zval(return_value, &cookie);
                        }
                        zend_string_release(zs);
@@ -121,14 +127,12 @@ static zend_function_entry php_http_client_response_methods[] = {
        EMPTY_FUNCTION_ENTRY
 };
 
-zend_class_entry *php_http_client_response_class_entry;
-
 PHP_MINIT_FUNCTION(http_client_response)
 {
        zend_class_entry ce = {0};
 
        INIT_NS_CLASS_ENTRY(ce, "http\\Client", "Response", php_http_client_response_methods);
-       php_http_client_response_class_entry = zend_register_internal_class_ex(&ce, php_http_message_class_entry);
+       php_http_client_response_class_entry = zend_register_internal_class_ex(&ce, php_http_message_get_class_entry());
 
        zend_declare_property_null(php_http_client_response_class_entry, ZEND_STRL("transferInfo"), ZEND_ACC_PROTECTED);
 
index 15d004ef83f50055a454cf8b3b1afe0c3ad27b33..7a47cbea0039fe2b5627e21d80b53120548106b8 100644 (file)
@@ -13,7 +13,7 @@
 #ifndef PHP_HTTP_CLIENT_RESPONSE_H
 #define PHP_HTTP_CLIENT_RESPONSE_H
 
-PHP_HTTP_API zend_class_entry *php_http_client_response_class_entry;
+PHP_HTTP_API zend_class_entry *php_http_get_client_response_class_entry(void);
 PHP_MINIT_FUNCTION(http_client_response);
 
 #endif /* PHP_HTTP_CLIENT_RESPONSE_H */
index 9625401aecdec149fdcaff522bd9e5f1269054ca..67b449427f7a90b6f2c1aaace7896436c2848050 100644 (file)
@@ -366,6 +366,11 @@ void php_http_cookie_list_to_string(php_http_cookie_list_t *list, char **str, si
 }
 
 
+static zend_class_entry *php_http_cookie_class_entry;
+zend_class_entry *php_http_cookie_get_class_entry(void)
+{
+       return php_http_cookie_class_entry;
+}
 
 static zend_object_handlers php_http_cookie_object_handlers;
 
@@ -439,7 +444,7 @@ static PHP_METHOD(HttpCookie, __construct)
 
        obj = PHP_HTTP_OBJ(NULL, getThis());
 
-       zend_replace_error_handling(EH_THROW, php_http_exception_runtime_class_entry, &zeh);
+       zend_replace_error_handling(EH_THROW, php_http_get_exception_runtime_class_entry(), &zeh);
        if (zcookie) {
 
                if (allowed_extras && zend_hash_num_elements(allowed_extras)) {
@@ -1010,8 +1015,6 @@ static zend_function_entry php_http_cookie_methods[] = {
        EMPTY_FUNCTION_ENTRY
 };
 
-zend_class_entry *php_http_cookie_class_entry;
-
 PHP_MINIT_FUNCTION(http_cookie)
 {
        zend_class_entry ce = {0};
index f7dbf8d1101173b9e2c03e7e57d358e9ff18b467..e7b924e3c9eb9c4bd296a3754475f5356ac0feda 100644 (file)
@@ -53,7 +53,7 @@ PHP_HTTP_API void php_http_cookie_list_to_string(php_http_cookie_list_t *list, c
 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;
+PHP_HTTP_API zend_class_entry *php_http_cookie_get_class_entry(void);
 
 typedef struct php_http_cookie_object {
        php_http_cookie_list_t *list;
index e7557a0852c0daeea1679ee837d5cda13c490727..7fbe7c7a51d49859cbcce173de3bea6083963f91 100644 (file)
@@ -943,6 +943,27 @@ void php_http_encoding_stream_object_free(zend_object *object)
        zend_object_std_dtor(object);
 }
 
+static zend_class_entry *php_http_encoding_stream_class_entry;
+zend_class_entry *php_http_get_encoding_stream_class_entry(void)
+{
+       return php_http_encoding_stream_class_entry;
+}
+static zend_class_entry *php_http_deflate_stream_class_entry;
+zend_class_entry *php_http_get_deflate_stream_class_entry(void)
+{
+       return php_http_deflate_stream_class_entry;
+}
+static zend_class_entry *php_http_inflate_stream_class_entry;
+zend_class_entry *php_http_get_inflate_stream_class_entry(void)
+{
+       return php_http_inflate_stream_class_entry;
+}
+static zend_class_entry *php_http_dechunk_stream_class_entry;
+zend_class_entry *php_http_get_dechunk_stream_class_entry(void)
+{
+       return php_http_dechunk_stream_class_entry;
+}
+
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpEncodingStream___construct, 0, 0, 0)
        ZEND_ARG_INFO(0, flags)
 ZEND_END_ARG_INFO();
@@ -1165,11 +1186,6 @@ static zend_function_entry php_http_dechunk_stream_methods[] = {
        EMPTY_FUNCTION_ENTRY
 };
 
-zend_class_entry *php_http_encoding_stream_class_entry;
-zend_class_entry *php_http_deflate_stream_class_entry;
-zend_class_entry *php_http_inflate_stream_class_entry;
-zend_class_entry *php_http_dechunk_stream_class_entry;
-
 PHP_MINIT_FUNCTION(http_encoding)
 {
        zend_class_entry ce = {0};
index ea767dd1f267526e92afaa574711bbb92e3c40d5..a924eaf4f1206461ace68454831a0cd3680d9ba6 100644 (file)
@@ -170,16 +170,16 @@ typedef struct php_http_encoding_stream_object {
        zend_object zo;
 } php_http_encoding_stream_object_t;
 
-PHP_HTTP_API zend_class_entry *php_http_encoding_stream_class_entry;
+PHP_HTTP_API zend_class_entry *php_http_get_encoding_stream_class_entry(void);
 
 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;
-PHP_HTTP_API zend_class_entry *php_http_dechunk_stream_class_entry;
+PHP_HTTP_API zend_class_entry *php_http_get_deflate_stream_class_entry(void);
+PHP_HTTP_API zend_class_entry *php_http_get_inflate_stream_class_entry(void);
+PHP_HTTP_API zend_class_entry *php_http_get_dechunk_stream_class_entry(void);
 
 #endif
 
index df22d5a7134a29eceb4f43ca107a9d943a9203da..21bd89ab73d504a51a7c08ffe0a3dfec095bd7ca 100644 (file)
@@ -555,12 +555,12 @@ static PHP_METHOD(HttpEnv, getRequestBody)
 {
        php_http_message_body_t *body;
        php_http_message_body_object_t *body_obj;
-       zend_class_entry *class_entry = php_http_message_body_class_entry;
+       zend_class_entry *class_entry = php_http_get_message_body_class_entry();
 
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &class_entry), invalid_arg, return);
 
        body = php_http_env_get_request_body();
-       if (SUCCESS == php_http_new((void *) &body_obj, class_entry, (php_http_new_t) php_http_message_body_object_new_ex, php_http_message_body_class_entry, body)) {
+       if (SUCCESS == php_http_new((void *) &body_obj, class_entry, (php_http_new_t) php_http_message_body_object_new_ex, php_http_get_message_body_class_entry(), body)) {
                php_http_message_body_addref(body);
                RETVAL_OBJ(&body_obj->zo);
        }
@@ -795,7 +795,11 @@ static zend_function_entry php_http_env_methods[] = {
        EMPTY_FUNCTION_ENTRY
 };
 
-zend_class_entry *php_http_env_class_entry;
+static zend_class_entry *php_http_env_class_entry;
+zend_class_entry *php_http_env_get_class_entry(void)
+{
+       return php_http_env_class_entry;
+}
 
 PHP_MINIT_FUNCTION(http_env)
 {
index 273ba16c4ffa9c0481184d41a2ff8cda46ab9ca0..829274470c57d6f72311f811e8bfb4df19b766c6 100644 (file)
@@ -76,7 +76,7 @@ static inline zend_bool php_http_env_got_server_var(const char *v)
 }
 
 
-PHP_HTTP_API zend_class_entry *php_http_env_class_entry;
+PHP_HTTP_API zend_class_entry *php_http_env_get_class_entry(void);
 PHP_MINIT_FUNCTION(http_env);
 PHP_RSHUTDOWN_FUNCTION(http_env);
 
index 0ee68f464ade730199dc260857d70c221072bc61..b5454ed89253bfde4d999c5a56faa8667a57ed16 100644 (file)
@@ -117,6 +117,11 @@ static int grab_files(zval *val, int argc, va_list argv, zend_hash_key *key)
                } \
        } while(0)
 
+static zend_class_entry *php_http_env_request_class_entry;
+zend_class_entry *php_http_get_env_request_class_entry(void)
+{
+       return php_http_env_request_class_entry;
+}
 
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpEnvRequest___construct, 0, 0, 0)
 ZEND_END_ARG_INFO();
@@ -133,19 +138,19 @@ static PHP_METHOD(HttpEnvRequest, __construct)
        php_http_expect(obj->message = php_http_message_init_env(obj->message, PHP_HTTP_REQUEST), unexpected_val, return);
 
        zsg = php_http_env_get_superglobal(ZEND_STRL("_GET"));
-       object_init_ex(&zqs, php_http_querystring_class_entry);
+       object_init_ex(&zqs, php_http_querystring_get_class_entry());
        php_http_expect(SUCCESS == php_http_querystring_ctor(&zqs, zsg), unexpected_val, return);
        zend_update_property(php_http_env_request_class_entry, getThis(), ZEND_STRL("query"), &zqs);
        zval_ptr_dtor(&zqs);
 
        zsg = php_http_env_get_superglobal(ZEND_STRL("_POST"));
-       object_init_ex(&zqs, php_http_querystring_class_entry);
+       object_init_ex(&zqs, php_http_querystring_get_class_entry());
        php_http_expect(SUCCESS == php_http_querystring_ctor(&zqs, zsg), unexpected_val, return);
        zend_update_property(php_http_env_request_class_entry, getThis(), ZEND_STRL("form"), &zqs);
        zval_ptr_dtor(&zqs);
 
        zsg = php_http_env_get_superglobal(ZEND_STRL("_COOKIE"));
-       object_init_ex(&zqs, php_http_querystring_class_entry);
+       object_init_ex(&zqs, php_http_querystring_get_class_entry());
        php_http_expect(SUCCESS == php_http_querystring_ctor(&zqs, zsg), unexpected_val, return);
        zend_update_property(php_http_env_request_class_entry, getThis(), ZEND_STRL("cookie"), &zqs);
        zval_ptr_dtor(&zqs);
@@ -248,14 +253,12 @@ static zend_function_entry php_http_env_request_methods[] = {
        EMPTY_FUNCTION_ENTRY
 };
 
-zend_class_entry *php_http_env_request_class_entry;
-
 PHP_MINIT_FUNCTION(http_env_request)
 {
        zend_class_entry ce = {0};
 
        INIT_NS_CLASS_ENTRY(ce, "http\\Env", "Request", php_http_env_request_methods);
-       php_http_env_request_class_entry = zend_register_internal_class_ex(&ce, php_http_message_class_entry);
+       php_http_env_request_class_entry = zend_register_internal_class_ex(&ce, php_http_message_get_class_entry());
 
        zend_declare_property_null(php_http_env_request_class_entry, ZEND_STRL("query"), ZEND_ACC_PROTECTED);
        zend_declare_property_null(php_http_env_request_class_entry, ZEND_STRL("form"), ZEND_ACC_PROTECTED);
index a97836be904e7542987278c47ff185a2f66cf6d2..a799134e01e2956b11cda534430c7ddf74705419 100644 (file)
@@ -13,7 +13,7 @@
 #ifndef PHP_HTTP_ENV_REQUEST_H
 #define PHP_HTTP_ENV_REQUEST_H
 
-PHP_HTTP_API zend_class_entry *php_http_env_request_class_entry;
+PHP_HTTP_API zend_class_entry *php_http_get_env_request_class_entry(void);
 PHP_MINIT_FUNCTION(http_env_request);
 
 #endif
index 9bc3f5bc394e743f3759dd0ee0da869b893266c1..63246988a5b0ba0ac39588eab26de5d6a2660bad 100644 (file)
@@ -82,7 +82,7 @@ static php_http_message_body_t *get_body(zval *options)
        php_http_message_body_t *body = NULL;
 
        if ((zbody = get_option(options, ZEND_STRL("body"), &zbody_tmp))) {
-               if ((Z_TYPE_P(zbody) == IS_OBJECT) && instanceof_function(Z_OBJCE_P(zbody), php_http_message_body_class_entry)) {
+               if ((Z_TYPE_P(zbody) == IS_OBJECT) && instanceof_function(Z_OBJCE_P(zbody), php_http_get_message_body_class_entry())) {
                        php_http_message_body_object_t *body_obj = PHP_HTTP_OBJ(NULL, zbody);
 
                        body = body_obj->body;
@@ -98,7 +98,7 @@ static php_http_message_t *get_request(zval *options)
        php_http_message_t *request = NULL;
 
        if ((zrequest = get_option(options, ZEND_STRL("request"), &zrequest_tmp))) {
-               if (Z_TYPE_P(zrequest) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zrequest), php_http_message_class_entry)) {
+               if (Z_TYPE_P(zrequest) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zrequest), php_http_message_get_class_entry())) {
                        php_http_message_object_t *request_obj = PHP_HTTP_OBJ(NULL, zrequest);
 
                        request = request_obj->message;
@@ -385,7 +385,7 @@ static ZEND_RESULT_CODE php_http_env_response_send_head(php_http_env_response_t
 
                        ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(zoption), zcookie)
                        {
-                               if (Z_TYPE_P(zcookie) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zcookie), php_http_cookie_class_entry)) {
+                               if (Z_TYPE_P(zcookie) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zcookie), php_http_cookie_get_class_entry())) {
                                        php_http_cookie_object_t *obj = PHP_HTTP_OBJ(NULL, zcookie);
                                        char *str;
                                        size_t len;
@@ -1178,7 +1178,7 @@ static PHP_METHOD(HttpEnvResponse, setEnvRequest)
 {
        zval *env_req = NULL;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|O", &env_req, php_http_message_class_entry), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|O", &env_req, php_http_message_get_class_entry()), invalid_arg, return);
 
        set_option(getThis(), ZEND_STRL("request"), IS_OBJECT, env_req, 0);
        RETVAL_ZVAL(getThis(), 1, 0);
@@ -1328,10 +1328,10 @@ static PHP_METHOD(HttpEnvResponse, setCookie)
 
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "z", &zcookie_new), invalid_arg, return);
 
-       zend_replace_error_handling(EH_THROW, php_http_exception_unexpected_val_class_entry, &zeh);
+       zend_replace_error_handling(EH_THROW, php_http_get_exception_unexpected_val_class_entry(), &zeh);
        switch (Z_TYPE_P(zcookie_new)) {
        case IS_OBJECT:
-               if (instanceof_function(Z_OBJCE_P(zcookie_new), php_http_cookie_class_entry)) {
+               if (instanceof_function(Z_OBJCE_P(zcookie_new), php_http_cookie_get_class_entry())) {
                        Z_ADDREF_P(zcookie_new);
                        break;
                }
@@ -1339,7 +1339,7 @@ static PHP_METHOD(HttpEnvResponse, setCookie)
        case IS_ARRAY:
                list = php_http_cookie_list_from_struct(NULL, zcookie_new);
                zcookie_new = &tmp;
-               ZVAL_OBJECT(zcookie_new, &php_http_cookie_object_new_ex(php_http_cookie_class_entry, list)->zo, 0);
+               ZVAL_OBJECT(zcookie_new, &php_http_cookie_object_new_ex(php_http_cookie_get_class_entry(), list)->zo, 0);
                break;
 
        default:
@@ -1347,7 +1347,7 @@ static PHP_METHOD(HttpEnvResponse, setCookie)
                list = php_http_cookie_list_parse(NULL, zs->val, zs->len, 0, NULL);
                zend_string_release(zs);
                zcookie_new = &tmp;
-               ZVAL_OBJECT(zcookie_new, &php_http_cookie_object_new_ex(php_http_cookie_class_entry, list)->zo, 0);
+               ZVAL_OBJECT(zcookie_new, &php_http_cookie_object_new_ex(php_http_cookie_get_class_entry(), list)->zo, 0);
        }
        zend_restore_error_handling(&zeh);
 
@@ -1412,14 +1412,18 @@ static zend_function_entry php_http_env_response_methods[] = {
        EMPTY_FUNCTION_ENTRY
 };
 
-zend_class_entry *php_http_env_response_class_entry;
+static zend_class_entry *php_http_env_response_class_entry;
+zend_class_entry *php_http_get_env_response_class_entry(void)
+{
+       return php_http_env_response_class_entry;
+}
 
 PHP_MINIT_FUNCTION(http_env_response)
 {
        zend_class_entry ce = {0};
 
        INIT_NS_CLASS_ENTRY(ce, "http\\Env", "Response", php_http_env_response_methods);
-       php_http_env_response_class_entry = zend_register_internal_class_ex(&ce, php_http_message_class_entry);
+       php_http_env_response_class_entry = zend_register_internal_class_ex(&ce, php_http_message_get_class_entry());
 
        zend_declare_class_constant_long(php_http_env_response_class_entry, ZEND_STRL("CONTENT_ENCODING_NONE"), PHP_HTTP_CONTENT_ENCODING_NONE);
        zend_declare_class_constant_long(php_http_env_response_class_entry, ZEND_STRL("CONTENT_ENCODING_GZIP"), PHP_HTTP_CONTENT_ENCODING_GZIP);
index ae1441d37fab8032ba577c14088bbbf4218ce051..62fb8f755ee88f286cb1cd02b9154a36785c3d43 100644 (file)
@@ -70,7 +70,7 @@ PHP_HTTP_API void php_http_env_response_free(php_http_env_response_t **r);
 PHP_HTTP_API php_http_cache_status_t php_http_env_is_response_cached_by_etag(zval *options, const char *header_str, size_t header_len, php_http_message_t *request);
 PHP_HTTP_API php_http_cache_status_t php_http_env_is_response_cached_by_last_modified(zval *options, const char *header_str, size_t header_len, php_http_message_t *request);
 
-PHP_HTTP_API zend_class_entry *php_http_env_response_class_entry;
+PHP_HTTP_API zend_class_entry *php_http_get_env_response_class_entry();
 PHP_MINIT_FUNCTION(http_env_response);
 
 #endif
index bae09f983dfdca4a74ce8e64abe072ca910334a1..4c83028af7ec739d817b89d5e2a6285320aa2b3d 100644 (file)
@@ -30,16 +30,56 @@ static void php_http_exception_hook(zval *ex)
 }
 #endif
 
-zend_class_entry *php_http_exception_interface_class_entry;
-zend_class_entry *php_http_exception_runtime_class_entry;
-zend_class_entry *php_http_exception_unexpected_val_class_entry;
-zend_class_entry *php_http_exception_bad_method_call_class_entry;
-zend_class_entry *php_http_exception_invalid_arg_class_entry;
-zend_class_entry *php_http_exception_bad_header_class_entry;
-zend_class_entry *php_http_exception_bad_url_class_entry;
-zend_class_entry *php_http_exception_bad_message_class_entry;
-zend_class_entry *php_http_exception_bad_conversion_class_entry;
-zend_class_entry *php_http_exception_bad_querystring_class_entry;
+static zend_class_entry *php_http_exception_interface_class_entry;
+zend_class_entry *php_http_get_exception_interface_class_entry(void)
+{
+       return php_http_exception_interface_class_entry;
+}
+static zend_class_entry *php_http_exception_runtime_class_entry;
+zend_class_entry *php_http_get_exception_runtime_class_entry(void)
+{
+       return php_http_exception_runtime_class_entry;
+}
+static zend_class_entry *php_http_exception_unexpected_val_class_entry;
+zend_class_entry *php_http_get_exception_unexpected_val_class_entry(void)
+{
+       return php_http_exception_unexpected_val_class_entry;
+}
+static zend_class_entry *php_http_exception_bad_method_call_class_entry;
+zend_class_entry *php_http_get_exception_bad_method_call_class_entry(void)
+{
+       return php_http_exception_bad_method_call_class_entry;
+}
+static zend_class_entry *php_http_exception_invalid_arg_class_entry;
+zend_class_entry *php_http_get_exception_invalid_arg_class_entry(void)
+{
+       return php_http_exception_invalid_arg_class_entry;
+}
+static zend_class_entry *php_http_exception_bad_header_class_entry;
+zend_class_entry *php_http_get_exception_bad_header_class_entry(void)
+{
+       return php_http_exception_bad_header_class_entry;
+}
+static zend_class_entry *php_http_exception_bad_url_class_entry;
+zend_class_entry *php_http_get_exception_bad_url_class_entry(void)
+{
+       return php_http_exception_bad_url_class_entry;
+}
+static zend_class_entry *php_http_exception_bad_message_class_entry;
+zend_class_entry *php_http_get_exception_bad_message_class_entry(void)
+{
+       return php_http_exception_bad_message_class_entry;
+}
+static zend_class_entry *php_http_exception_bad_conversion_class_entry;
+zend_class_entry *php_http_get_exception_bad_conversion_class_entry(void)
+{
+       return php_http_exception_bad_conversion_class_entry;
+}
+static zend_class_entry *php_http_exception_bad_querystring_class_entry;
+zend_class_entry *php_http_get_exception_bad_querystring_class_entry(void)
+{
+       return php_http_exception_bad_querystring_class_entry;
+}
 
 PHP_MINIT_FUNCTION(http_exception)
 {
index eaf7a13c2812ba31d0ea3806cbbf51edcc3e6d46..5acf28031a9ad33758f25eacc38b61f8b698c4e1 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, fmt, __VA_ARGS__)
+       zend_throw_exception_ex(php_http_get_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); \
+               zend_replace_error_handling(EH_THROW, php_http_get_exception_ ##e## _class_entry(), &__zeh); \
                if (!(test)) { \
                        zend_restore_error_handling(&__zeh); \
                        fail; \
                zend_restore_error_handling(&__zeh); \
        } while(0)
 
-PHP_HTTP_API zend_class_entry *php_http_exception_interface_class_entry;
-PHP_HTTP_API zend_class_entry *php_http_exception_runtime_class_entry;
-PHP_HTTP_API zend_class_entry *php_http_exception_unexpected_val_class_entry;
-PHP_HTTP_API zend_class_entry *php_http_exception_bad_method_call_class_entry;
-PHP_HTTP_API zend_class_entry *php_http_exception_invalid_arg_class_entry;
-PHP_HTTP_API zend_class_entry *php_http_exception_bad_header_class_entry;
-PHP_HTTP_API zend_class_entry *php_http_exception_bad_url_class_entry;
-PHP_HTTP_API zend_class_entry *php_http_exception_bad_message_class_entry;
-PHP_HTTP_API zend_class_entry *php_http_exception_bad_conversion_class_entry;
-PHP_HTTP_API zend_class_entry *php_http_exception_bad_querystring_class_entry;
+PHP_HTTP_API zend_class_entry *php_http_get_exception_interface_class_entry(void);
+PHP_HTTP_API zend_class_entry *php_http_get_exception_runtime_class_entry(void);
+PHP_HTTP_API zend_class_entry *php_http_get_exception_unexpected_val_class_entry(void);
+PHP_HTTP_API zend_class_entry *php_http_get_exception_bad_method_call_class_entry(void);
+PHP_HTTP_API zend_class_entry *php_http_get_exception_invalid_arg_class_entry(void);
+PHP_HTTP_API zend_class_entry *php_http_get_exception_bad_header_class_entry(void);
+PHP_HTTP_API zend_class_entry *php_http_get_exception_bad_url_class_entry(void);
+PHP_HTTP_API zend_class_entry *php_http_get_exception_bad_message_class_entry(void);
+PHP_HTTP_API zend_class_entry *php_http_get_exception_bad_conversion_class_entry(void);
+PHP_HTTP_API zend_class_entry *php_http_get_exception_bad_querystring_class_entry(void);
 
 PHP_MINIT_FUNCTION(http_exception);
 
index d4f2b510b311e69f3f2bde61fd6825f97ed81748..f31e0847e2f22dab40782a68211fb7310186b9c4 100644 (file)
@@ -116,6 +116,12 @@ zend_string *php_http_header_value_to_string(zval *header)
        }
 }
 
+static zend_class_entry *php_http_header_class_entry;
+zend_class_entry *php_http_header_get_class_entry(void)
+{
+       return php_http_header_class_entry;
+}
+
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpHeader___construct, 0, 0, 0)
        ZEND_ARG_INFO(0, name)
        ZEND_ARG_INFO(0, value)
@@ -276,7 +282,7 @@ PHP_METHOD(HttpHeader, getParams)
        
        ZVAL_STRINGL(&zctor, "__construct", lenof("__construct"));
        
-       object_init_ex(&zparams_obj, php_http_params_class_entry);
+       object_init_ex(&zparams_obj, php_http_params_get_class_entry());
        
        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, &value_tmp));
@@ -356,8 +362,6 @@ static zend_function_entry php_http_header_methods[] = {
        EMPTY_FUNCTION_ENTRY
 };
 
-zend_class_entry *php_http_header_class_entry;
-
 PHP_MINIT_FUNCTION(http_header)
 {
        zend_class_entry ce = {0};
index 88ebd1048075e5faea6c606f4ef838ca5faa8e51..1ba9ef59d534df94ec58721a74bfe1b4cd506879 100644 (file)
@@ -23,7 +23,7 @@ PHP_HTTP_API void php_http_header_to_string(php_http_buffer_t *str, HashTable *h
 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_HTTP_API zend_class_entry *php_http_header_get_class_entry(void);
 PHP_MINIT_FUNCTION(http_header);
 
 #endif
index 5dfaeddfe8c9067c2a6393d82ed1a0d20b535d28..fb844526dcc9bbebdb887fe4868ab67564ecafb0 100644 (file)
@@ -333,7 +333,11 @@ php_http_header_parser_state_t php_http_header_parser_parse_stream(php_http_head
        return PHP_HTTP_HEADER_PARSER_STATE_DONE;
 }
 
-zend_class_entry *php_http_header_parser_class_entry;
+static zend_class_entry *php_http_header_parser_class_entry;
+zend_class_entry *php_http_get_header_parser_class_entry(void)
+{
+       return php_http_header_parser_class_entry;
+}
 static zend_object_handlers php_http_header_parser_object_handlers;
 
 zend_object *php_http_header_parser_object_new(zend_class_entry *ce)
@@ -425,7 +429,7 @@ static PHP_METHOD(HttpHeaderParser, stream)
 
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "rlz", &zstream, &flags, &zmsg), invalid_arg, return);
 
-       zend_replace_error_handling(EH_THROW, php_http_exception_unexpected_val_class_entry, &zeh);
+       zend_replace_error_handling(EH_THROW, php_http_get_exception_unexpected_val_class_entry(), &zeh);
        php_stream_from_zval(s, zstream);
        zend_restore_error_handling(&zeh);
 
index 33707bd6fb5709ec5643fe950567e9747447bca5..c22c6a74408f8dca947281f63198c65e32dd5fe1 100644 (file)
@@ -55,7 +55,7 @@ typedef struct php_http_header_parser_object {
        zend_object zo;
 } php_http_header_parser_object_t;
 
-PHP_HTTP_API zend_class_entry *php_http_header_parser_class_entry;
+PHP_HTTP_API zend_class_entry *php_http_get_header_parser_class_entry(void);
 
 PHP_MINIT_FUNCTION(http_header_parser);
 
index 74036f9db0fa6b125e0abec33120eead2fb8d19c..45f584f6094e5fff1c1561cf119660f15dcabe05 100644 (file)
@@ -512,6 +512,12 @@ void php_http_message_free(php_http_message_t **message)
        }
 }
 
+static zend_class_entry *php_http_message_class_entry;
+zend_class_entry *php_http_message_get_class_entry(void)
+{
+       return php_http_message_class_entry;
+}
+
 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);
 
@@ -763,14 +769,14 @@ ZEND_RESULT_CODE php_http_message_object_set_body(php_http_message_object_t *msg
                        is_resource:
 
                        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))) {
+                       if (!(body_obj = php_http_message_body_object_new_ex(php_http_get_message_body_class_entry(), body))) {
                                php_http_message_body_free(&body);
                                return FAILURE;
                        }
                        break;
 
                case IS_OBJECT:
-                       if (instanceof_function(Z_OBJCE_P(zbody), php_http_message_body_class_entry)) {
+                       if (instanceof_function(Z_OBJCE_P(zbody), php_http_get_message_body_class_entry())) {
                                Z_ADDREF_P(zbody);
                                body_obj = PHP_HTTP_OBJ(NULL, zbody);
                                break;
@@ -807,7 +813,7 @@ ZEND_RESULT_CODE php_http_message_object_set_body(php_http_message_object_t *msg
 ZEND_RESULT_CODE php_http_message_object_init_body_object(php_http_message_object_t *obj)
 {
        php_http_message_body_addref(obj->message->body);
-       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);
+       return php_http_new((void *) &obj->body, php_http_get_message_body_class_entry(), (php_http_new_t) php_http_message_body_object_new_ex, NULL, obj->message->body);
 }
 
 zend_object *php_http_message_object_new(zend_class_entry *ce)
@@ -828,7 +834,7 @@ php_http_message_object_t *php_http_message_object_new_ex(zend_class_entry *ce,
                if (msg->parent) {
                        o->parent = php_http_message_object_new_ex(ce, msg->parent);
                }
-               o->body = php_http_message_body_object_new_ex(php_http_message_body_class_entry, php_http_message_body_init(&msg->body, NULL));
+               o->body = php_http_message_body_object_new_ex(php_http_get_message_body_class_entry(), php_http_message_body_init(&msg->body, NULL));
        }
 
        o->zo.handlers = &php_http_message_object_handlers;
@@ -1021,13 +1027,13 @@ static PHP_METHOD(HttpMessage, __construct)
 
        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);
+       zend_replace_error_handling(EH_THROW, php_http_get_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);
+               zend_replace_error_handling(EH_THROW, php_http_get_exception_unexpected_val_class_entry(), &zeh);
                php_stream_from_zval(s, zmessage);
                zend_restore_error_handling(&zeh);
 
@@ -1097,7 +1103,7 @@ static PHP_METHOD(HttpMessage, setBody)
 {
        zval *zbody;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &zbody, php_http_message_body_class_entry)) {
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &zbody, php_http_get_message_body_class_entry())) {
                php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
@@ -1113,7 +1119,7 @@ static PHP_METHOD(HttpMessage, addBody)
 {
        zval *new_body;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &new_body, php_http_message_body_class_entry)) {
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &new_body, php_http_get_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);
 
@@ -1142,7 +1148,7 @@ static PHP_METHOD(HttpMessage, getHeader)
                if ((header = php_http_message_header(obj->message, header_str, header_len))) {
                        if (!header_ce) {
                                RETURN_ZVAL(header, 1, 0);
-                       } else if (instanceof_function(header_ce, php_http_header_class_entry)) {
+                       } else if (instanceof_function(header_ce, php_http_header_get_class_entry())) {
                                php_http_object_method_t cb;
                                zval argv[2];
 
@@ -1589,7 +1595,7 @@ static PHP_METHOD(HttpMessage, setRequestUrl)
                return;
        }
 
-       zend_replace_error_handling(EH_THROW, php_http_exception_bad_url_class_entry, &zeh);
+       zend_replace_error_handling(EH_THROW, php_http_get_exception_bad_url_class_entry(), &zeh);
        url = php_http_url_from_zval(zurl, ~0);
        zend_restore_error_handling(&zeh);
 
@@ -1988,8 +1994,6 @@ static zend_function_entry php_http_message_methods[] = {
        EMPTY_FUNCTION_ENTRY
 };
 
-zend_class_entry *php_http_message_class_entry;
-
 PHP_MINIT_FUNCTION(http_message)
 {
        zend_class_entry ce = {0};
index 2f995074173add6e49d33d058e6180f12be1c052..eb5aa0d0df08bdb23323a08218f5897aa0cf3c8a 100644 (file)
@@ -92,7 +92,7 @@ typedef struct php_http_message_object {
        zend_object zo;
 } php_http_message_object_t;
 
-PHP_HTTP_API zend_class_entry *php_http_message_class_entry;
+PHP_HTTP_API zend_class_entry *php_http_message_get_class_entry(void);
 
 PHP_MINIT_FUNCTION(http_message);
 PHP_MSHUTDOWN_FUNCTION(http_message);
index d629ae53ad5d137eca73be4c5fc7f51ce538e916..43aba7f4a8d2e731f31fae42e145ec28d2643142 100644 (file)
@@ -546,6 +546,12 @@ php_http_message_t *php_http_message_body_split(php_http_message_body_t *body, c
        return msg;
 }
 
+static zend_class_entry *php_http_message_body_class_entry;
+zend_class_entry *php_http_get_message_body_class_entry(void)
+{
+       return php_http_message_body_class_entry;
+}
+
 static zend_object_handlers php_http_message_body_object_handlers;
 
 zend_object *php_http_message_body_object_new(zend_class_entry *ce)
@@ -774,14 +780,14 @@ PHP_METHOD(HttpMessageBody, addPart)
        php_http_message_object_t *mobj;
        zend_error_handling zeh;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &zobj, php_http_message_class_entry), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &zobj, php_http_message_get_class_entry()), invalid_arg, return);
 
        obj = PHP_HTTP_OBJ(NULL, getThis());
        mobj = PHP_HTTP_OBJ(NULL, zobj);
 
        PHP_HTTP_MESSAGE_BODY_OBJECT_INIT(obj);
 
-       zend_replace_error_handling(EH_THROW, php_http_exception_runtime_class_entry, &zeh);
+       zend_replace_error_handling(EH_THROW, php_http_get_exception_runtime_class_entry(), &zeh);
        php_http_message_body_add_part(obj->body, mobj->message);
        zend_restore_error_handling(&zeh);
 
@@ -874,8 +880,6 @@ static zend_function_entry php_http_message_body_methods[] = {
        EMPTY_FUNCTION_ENTRY
 };
 
-zend_class_entry *php_http_message_body_class_entry;
-
 PHP_MINIT_FUNCTION(http_message_body)
 {
        zend_class_entry ce = {0};
index 92353f7319e48f89daeed35922dd3f02dbc00602..4e224d00a35ef7e35a3b75d13d5a42ed9393375a 100644 (file)
@@ -60,7 +60,7 @@ typedef struct php_http_message_body_object {
        zend_object zo;
 } php_http_message_body_object_t;
 
-PHP_HTTP_API zend_class_entry *php_http_message_body_class_entry;
+PHP_HTTP_API zend_class_entry *php_http_get_message_body_class_entry(void);
 PHP_MINIT_FUNCTION(http_message_body);
 
 zend_object *php_http_message_body_object_new(zend_class_entry *ce);
index 535a2b3849fd1b103aead321333e4104a00ba25c..db935d913cbc694f3b0000bdd0009dbc64e4d5cc 100644 (file)
@@ -534,7 +534,11 @@ php_http_message_parser_state_t php_http_message_parser_parse(php_http_message_p
        return php_http_message_parser_state_is(parser);
 }
 
-zend_class_entry *php_http_message_parser_class_entry;
+static zend_class_entry *php_http_message_parser_class_entry;
+zend_class_entry *php_http_get_message_parser_class_entry(void)
+{
+       return php_http_message_parser_class_entry;
+}
 static zend_object_handlers php_http_message_parser_object_handlers;
 
 zend_object *php_http_message_parser_object_new(zend_class_entry *ce)
@@ -607,7 +611,7 @@ static PHP_METHOD(HttpMessageParser, parse)
        ZVAL_NULL(zmsg);
        if (parser_obj->parser->message) {
                php_http_message_t *msg_cpy = php_http_message_copy(parser_obj->parser->message, NULL);
-               php_http_message_object_t *msg_obj = php_http_message_object_new_ex(php_http_message_class_entry, msg_cpy);
+               php_http_message_object_t *msg_obj = php_http_message_object_new_ex(php_http_message_get_class_entry(), msg_cpy);
                ZVAL_OBJ(zmsg, &msg_obj->zo);
        }
 }
@@ -627,7 +631,7 @@ static PHP_METHOD(HttpMessageParser, stream)
 
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "rlz", &zstream, &flags, &zmsg), invalid_arg, return);
 
-       zend_replace_error_handling(EH_THROW, php_http_exception_unexpected_val_class_entry, &zeh);
+       zend_replace_error_handling(EH_THROW, php_http_get_exception_unexpected_val_class_entry(), &zeh);
        php_stream_from_zval(s, zstream);
        zend_restore_error_handling(&zeh);
 
@@ -639,7 +643,7 @@ static PHP_METHOD(HttpMessageParser, stream)
        ZVAL_NULL(zmsg);
        if (parser_obj->parser->message) {
                php_http_message_t *msg_cpy = php_http_message_copy(parser_obj->parser->message, NULL);
-               php_http_message_object_t *msg_obj = php_http_message_object_new_ex(php_http_message_class_entry, msg_cpy);
+               php_http_message_object_t *msg_obj = php_http_message_object_new_ex(php_http_message_get_class_entry(), msg_cpy);
                ZVAL_OBJ(zmsg, &msg_obj->zo);
        }
 }
index fa6385845bc7a8906f974430bf378ba1c216a996..9b6174d12951ac26030ec82bc8f8d0c8276e369b 100644 (file)
@@ -60,7 +60,7 @@ typedef struct php_http_message_parser_object {
        zend_object zo;
 } php_http_message_parser_object_t;
 
-PHP_HTTP_API zend_class_entry *php_http_message_parser_class_entry;
+PHP_HTTP_API zend_class_entry *php_http_get_message_parser_class_entry(void);
 
 PHP_MINIT_FUNCTION(http_message_parser);
 
index b51ab712657cab9e0fff62a8ca3d7ee982f2151c..8db5c353bd18c004ecc8bef617431577fafcb526 100644 (file)
@@ -1027,6 +1027,12 @@ void php_http_params_separator_free(php_http_params_token_t **separator)
        }
 }
 
+static zend_class_entry *php_http_params_class_entry;
+zend_class_entry *php_http_params_get_class_entry(void)
+{
+       return php_http_params_class_entry;
+}
+
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams___construct, 0, 0, 0)
        ZEND_ARG_INFO(0, params)
        ZEND_ARG_INFO(0, param_sep)
@@ -1043,7 +1049,7 @@ PHP_METHOD(HttpParams, __construct)
 
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|z!/z/z/z/l", &zparams, &param_sep, &arg_sep, &val_sep, &flags), invalid_arg, return);
 
-       zend_replace_error_handling(EH_THROW, php_http_exception_runtime_class_entry, &zeh);
+       zend_replace_error_handling(EH_THROW, php_http_get_exception_runtime_class_entry(), &zeh);
        {
                switch (ZEND_NUM_ARGS()) {
                        case 5:
@@ -1283,8 +1289,6 @@ static zend_function_entry php_http_params_methods[] = {
        EMPTY_FUNCTION_ENTRY
 };
 
-zend_class_entry *php_http_params_class_entry;
-
 PHP_MINIT_FUNCTION(http_params)
 {
        zend_class_entry ce = {0};
index b8892101e15d28bc83d7590b34d6e3080e6127ab..433cf76fcd8e1e2d784377903648d4485e5204fb 100644 (file)
@@ -45,7 +45,7 @@ PHP_HTTP_API void php_http_params_separator_free(php_http_params_token_t **separ
 
 typedef php_http_object_t php_http_params_object_t;
 
-PHP_HTTP_API zend_class_entry *php_http_params_class_entry;
+PHP_HTTP_API zend_class_entry *php_http_params_get_class_entry(void);
 
 PHP_MINIT_FUNCTION(http_params);
 
index 5f4eff81a9a101414d4ffed647fcc9ae6c9a4f12..ea84d8d1e6fed8a94a74113144218892a2849074 100644 (file)
 #      include <ext/iconv/php_iconv.h>
 #endif
 
+static zend_class_entry *php_http_querystring_class_entry;
+zend_class_entry *php_http_querystring_get_class_entry(void)
+{
+       return php_http_querystring_class_entry;
+}
+
 #define QS_MERGE 1
 
 static inline void php_http_querystring_set(zval *instance, zval *params, int flags)
@@ -334,7 +340,7 @@ PHP_METHOD(HttpQueryString, __construct)
        
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|z", &params), invalid_arg, return);
 
-       zend_replace_error_handling(EH_THROW, php_http_exception_bad_querystring_class_entry, &zeh);
+       zend_replace_error_handling(EH_THROW, php_http_get_exception_bad_querystring_class_entry(), &zeh);
        php_http_querystring_set(getThis(), params, 0);
        zend_restore_error_handling(&zeh);
 }
@@ -477,7 +483,7 @@ PHP_METHOD(HttpQueryString, mod)
 
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "z", &params), invalid_arg, return);
        
-       zend_replace_error_handling(EH_THROW, php_http_exception_bad_querystring_class_entry, &zeh);
+       zend_replace_error_handling(EH_THROW, php_http_get_exception_bad_querystring_class_entry(), &zeh);
        ZVAL_OBJ(return_value, Z_OBJ_HT_P(instance)->clone_obj(instance));
        /* make sure we do not inherit the reference to _GET */
        SEPARATE_ZVAL(zend_read_property(Z_OBJCE_P(return_value), return_value, ZEND_STRL("queryArray"), 0, &qa_tmp));
@@ -655,8 +661,6 @@ PHP_METHOD(HttpQueryString, offsetUnset)
        zval_ptr_dtor(&param);
 }
 
-zend_class_entry *php_http_querystring_class_entry;
-
 static zend_function_entry php_http_querystring_methods[] = {
        PHP_ME(HttpQueryString, __construct, ai_HttpQueryString___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR|ZEND_ACC_FINAL)
 
index d41b8e9065ffce11455ba627a867bcf79f083403..dc45f31c452484a2039c1f6951984401a0f2ecb5 100644 (file)
@@ -28,7 +28,7 @@ typedef php_http_object_t php_http_querystring_object_t;
 #define PHP_HTTP_QUERYSTRING_TYPE_ARRAY                IS_ARRAY
 #define PHP_HTTP_QUERYSTRING_TYPE_OBJECT       IS_OBJECT
 
-PHP_HTTP_API zend_class_entry *php_http_querystring_class_entry;
+PHP_HTTP_API zend_class_entry *php_http_querystring_get_class_entry(void);
 
 PHP_MINIT_FUNCTION(http_querystring);
 
index 076171e8f7c29ecc40576c1c279b8b3c8d2b686a..cce4ba7b16ed40bd9944a74243a788eec4a501e1 100644 (file)
@@ -1556,6 +1556,19 @@ php_http_url_t *php_http_url_parse_authority(const char *str, size_t len, unsign
        return (php_http_url_t *) state;
 }
 
+static zend_class_entry *php_http_url_class_entry;
+static zend_class_entry *php_http_env_url_class_entry;
+
+zend_class_entry *php_http_url_get_class_entry(void)
+{
+       return php_http_url_class_entry;
+}
+
+zend_class_entry *php_http_get_env_url_class_entry(void)
+{
+       return php_http_env_url_class_entry;
+}
+
 ZEND_BEGIN_ARG_INFO_EX(ai_HttpUrl___construct, 0, 0, 0)
        ZEND_ARG_INFO(0, old_url)
        ZEND_ARG_INFO(0, new_url)
@@ -1564,12 +1577,17 @@ ZEND_END_ARG_INFO();
 PHP_METHOD(HttpUrl, __construct)
 {
        zval *new_url = NULL, *old_url = NULL;
-       zend_long flags = PHP_HTTP_URL_FROM_ENV;
+       zend_long flags = 0;
        zend_error_handling zeh;
 
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|z!z!l", &old_url, &new_url, &flags), invalid_arg, return);
 
-       zend_replace_error_handling(EH_THROW, php_http_exception_bad_url_class_entry, &zeh);
+       /* always set http\Url::FROM_ENV for instances of http\Env\Url */
+       if (instanceof_function(Z_OBJCE_P(getThis()), php_http_env_url_class_entry)) {
+               flags |= PHP_HTTP_URL_FROM_ENV;
+       }
+
+       zend_replace_error_handling(EH_THROW, php_http_get_exception_bad_url_class_entry(), &zeh);
        {
                php_http_url_t *res_purl, *new_purl = NULL, *old_purl = NULL;
 
@@ -1617,7 +1635,7 @@ PHP_METHOD(HttpUrl, mod)
 
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "z!|l", &new_url, &flags), invalid_arg, return);
 
-       zend_replace_error_handling(EH_THROW, php_http_exception_bad_url_class_entry, &zeh);
+       zend_replace_error_handling(EH_THROW, php_http_get_exception_bad_url_class_entry(), &zeh);
        {
                php_http_url_t *new_purl = NULL, *old_purl = NULL;
 
@@ -1691,8 +1709,6 @@ static zend_function_entry php_http_url_methods[] = {
        EMPTY_FUNCTION_ENTRY
 };
 
-zend_class_entry *php_http_url_class_entry;
-
 PHP_MINIT_FUNCTION(http_url)
 {
        zend_class_entry ce = {0};
@@ -1732,6 +1748,9 @@ PHP_MINIT_FUNCTION(http_url)
 #endif
        zend_declare_class_constant_long(php_http_url_class_entry, ZEND_STRL("PARSE_TOPCT"), PHP_HTTP_URL_PARSE_TOPCT);
 
+       INIT_NS_CLASS_ENTRY(ce, "http\\Env", "Url", php_http_url_methods);
+       php_http_env_url_class_entry = zend_register_internal_class_ex(&ce, php_http_url_class_entry);
+
        return SUCCESS;
 }
 
index 6ae0ac38af2b081d9967b1876b544e25fac0146c..40e98a0f3743aaed8d7426dc09311a2441f398ec 100644 (file)
@@ -83,7 +83,8 @@ static inline zend_bool php_http_url_is_empty(const php_http_url_t *url) {
        return !(url->scheme || url->pass || url->user || url->host || url->port ||     url->path || url->query || url->fragment);
 }
 
-PHP_HTTP_API zend_class_entry *php_http_url_class_entry;
+PHP_HTTP_API zend_class_entry *php_http_url_get_class_entry(void);
+PHP_HTTP_API zend_class_entry *php_http_get_env_url_class_entry(void);
 PHP_MINIT_FUNCTION(http_url);
 
 #define php_http_url_object_new php_http_object_new
index e1bc2504875273bcfc98f75593f222f5225d2a9e..647c7a529ab6a8d3bf9f98c4f49d18783b1a470a 100644 (file)
@@ -11,11 +11,12 @@ HTTP_HOST=example.com
 s=b&i=0&e=&a[]=1&a[]=2
 --FILE--
 <?php
-printf("%s\n", new http\Url);
-printf("%s\n", new http\Url("other", "index"));
-printf("%s\n", new http\Url(array("scheme" => "https", "port" => 443)));
-printf("%s\n", new http\Url(array("path" => "/./up/../down/../././//index.php/.", "query" => null), null, http\Url::SANITIZE_PATH|http\Url::FROM_ENV));
-printf("%s\n", new http\Url(null, null, 0));
+printf("%s\n", new http\Env\Url);
+printf("%s\n", new http\Env\Url("other", "index"));
+printf("%s\n", new http\Env\Url(array("scheme" => "https", "port" => 443)));
+printf("%s\n", new http\Env\Url(array("path" => "/./up/../down/../././//index.php/.", "query" => null), null, http\Url::SANITIZE_PATH|http\Url::FROM_ENV));
+printf("%s\n", new http\Env\Url(null, null, 0));
+printf("%s\n", new http\Url(null, null, http\Url::FROM_ENV));
 ?>
 DONE
 --EXPECTF--
@@ -23,5 +24,6 @@ http://example.com:55555/?s=b&i=0&e=&a[]=1&a[]=2
 http://example.com:55555/index?s=b&i=0&e=&a[]=1&a[]=2
 https://example.com/?s=b&i=0&e=&a[]=1&a[]=2
 http://example.com:55555/index.php/
-
+http://example.com:55555/?s=b&i=0&e=&a[]=1&a[]=2
+http://example.com:55555/?s=b&i=0&e=&a[]=1&a[]=2
 DONE