add http\Env::reset(); re: #90
authorMichael Wallner <mike@php.net>
Wed, 4 Aug 2021 08:45:57 +0000 (10:45 +0200)
committerMichael Wallner <mike@php.net>
Mon, 30 Aug 2021 07:20:13 +0000 (09:20 +0200)
src/php_http_env.c
src/php_http_env.h

index 5e14ed21a436cf1dc2c8c1c7435c0d4237ca2bc9..9c88822e3db948ec3331e4d706084f22db7be391 100644 (file)
 
 
 PHP_RSHUTDOWN_FUNCTION(http_env)
+{
+       php_http_env_reset();
+       return SUCCESS;
+}
+
+void php_http_env_reset()
 {
        if (PHP_HTTP_G->env.request.headers) {
                zend_hash_destroy(PHP_HTTP_G->env.request.headers);
@@ -24,13 +30,10 @@ PHP_RSHUTDOWN_FUNCTION(http_env)
        if (PHP_HTTP_G->env.request.body) {
                php_http_message_body_free(&PHP_HTTP_G->env.request.body);
        }
-
        if (PHP_HTTP_G->env.server_var) {
                zval_ptr_dtor(PHP_HTTP_G->env.server_var);
                PHP_HTTP_G->env.server_var = NULL;
        }
-
-       return SUCCESS;
 }
 
 void php_http_env_get_request_headers(HashTable *headers)
@@ -779,6 +782,15 @@ static PHP_METHOD(HttpEnv, negotiate)
        }
 }
 
+ZEND_BEGIN_ARG_INFO(ai_HttpEnv_reset, 0)
+ZEND_END_ARG_INFO();
+static PHP_METHOD(HttpEnv, reset)
+{
+       zend_parse_parameters_none();
+       php_http_env_reset();
+}
+
+
 static zend_function_entry php_http_env_methods[] = {
        PHP_ME(HttpEnv, getRequestHeader,              ai_HttpEnv_getRequestHeader,              ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
        PHP_ME(HttpEnv, getRequestBody,                ai_HttpEnv_getRequestBody,                ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
@@ -797,6 +809,8 @@ static zend_function_entry php_http_env_methods[] = {
        PHP_ME(HttpEnv, negotiateCharset,              ai_HttpEnv_negotiateCharset,              ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
        PHP_ME(HttpEnv, negotiate,                     ai_HttpEnv_negotiate,                     ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
 
+       PHP_ME(HttpEnv, reset,                         ai_HttpEnv_reset,                         ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+
        EMPTY_FUNCTION_ENTRY
 };
 
index 829274470c57d6f72311f811e8bfb4df19b766c6..d71ec474b71974f1d0d073f1211d9f530cc8e92d 100644 (file)
@@ -75,6 +75,7 @@ static inline zend_bool php_http_env_got_server_var(const char *v)
        return NULL != php_http_env_get_server_var(v, strlen(v), 1);
 }
 
+PHP_HTTP_API void php_http_env_reset();
 
 PHP_HTTP_API zend_class_entry *php_http_env_get_class_entry(void);
 PHP_MINIT_FUNCTION(http_env);