From: Michael Wallner Date: Wed, 4 Aug 2021 08:45:57 +0000 (+0200) Subject: add http\Env::reset(); re: #90 X-Git-Tag: v4.2.0~3 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=c74abe89c50e4053119f0424dd41ab5a221272a9;p=m6w6%2Fext-http add http\Env::reset(); re: #90 --- diff --git a/src/php_http_env.c b/src/php_http_env.c index 5e14ed2..9c88822 100644 --- a/src/php_http_env.c +++ b/src/php_http_env.c @@ -15,6 +15,12 @@ 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 }; diff --git a/src/php_http_env.h b/src/php_http_env.h index 8292744..d71ec47 100644 --- a/src/php_http_env.h +++ b/src/php_http_env.h @@ -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);