summaryrefslogtreecommitdiff
path: root/main/SAPI.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/SAPI.c')
-rw-r--r--main/SAPI.c52
1 files changed, 19 insertions, 33 deletions
diff --git a/main/SAPI.c b/main/SAPI.c
index a5a68f8c68..0a7f219e84 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -56,7 +54,7 @@ static void _type_dtor(zval *zv)
static void sapi_globals_ctor(sapi_globals_struct *sapi_globals)
{
memset(sapi_globals, 0, sizeof(*sapi_globals));
- zend_hash_init_ex(&sapi_globals->known_post_content_types, 8, NULL, _type_dtor, 1, 0);
+ zend_hash_init(&sapi_globals->known_post_content_types, 8, NULL, _type_dtor, 1);
php_setup_sapi_content_types();
}
@@ -111,18 +109,14 @@ SAPI_API void sapi_free_header(sapi_header_struct *sapi_header)
efree(sapi_header->header);
}
-/* {{{ proto bool header_register_callback(mixed callback)
- call a header function */
+/* {{{ call a header function */
PHP_FUNCTION(header_register_callback)
{
- zval *callback_func;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &callback_func) == FAILURE) {
- return;
- }
+ zend_fcall_info fci;
+ zend_fcall_info_cache fcc;
- if (!zend_is_callable(callback_func, 0, NULL)) {
- RETURN_FALSE;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "f", &fci, &fcc) == FAILURE) {
+ RETURN_THROWS();
}
if (Z_TYPE(SG(callback_func)) != IS_UNDEF) {
@@ -130,7 +124,7 @@ PHP_FUNCTION(header_register_callback)
SG(fci_cache) = empty_fcall_info_cache;
}
- ZVAL_COPY(&SG(callback_func), callback_func);
+ ZVAL_COPY(&SG(callback_func), &fci.function_name);
RETURN_TRUE;
}
@@ -612,7 +606,7 @@ static void sapi_remove_header(zend_llist *l, char *name, size_t len) {
}
}
-SAPI_API int sapi_add_header_ex(char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace)
+SAPI_API int sapi_add_header_ex(const char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace)
{
sapi_header_line ctr = {0};
int r;
@@ -624,7 +618,7 @@ SAPI_API int sapi_add_header_ex(char *header_line, size_t header_line_len, zend_
&ctr);
if (!duplicate)
- efree(header_line);
+ efree((void *) header_line);
return r;
}
@@ -684,7 +678,7 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg)
if (!p->line || !p->line_len) {
return FAILURE;
}
- header_line = p->line;
+ header_line = estrndup(p->line, p->line_len);
header_line_len = p->line_len;
http_response_code = p->response_code;
break;
@@ -701,8 +695,6 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg)
return FAILURE;
}
- header_line = estrndup(header_line, header_line_len);
-
/* cut off trailing spaces, linefeeds and carriage-returns */
if (header_line_len && isspace(header_line[header_line_len-1])) {
do {
@@ -770,13 +762,6 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg)
len--;
}
- /* Disable possible output compression for images */
- if (!strncmp(ptr, "image/", sizeof("image/")-1)) {
- zend_string *key = zend_string_init("zlib.output_compression", sizeof("zlib.output_compression")-1, 0);
- zend_alter_ini_entry_chars(key, "0", sizeof("0") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
- zend_string_release_ex(key, 0);
- }
-
mimetype = estrdup(ptr);
newlen = sapi_apply_default_charset(&mimetype, len);
if (!SG(sapi_headers).mimetype){
@@ -984,7 +969,7 @@ SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zva
return SUCCESS;
}
-SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void))
+SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void))
{
if (SG(sapi_started) && EG(current_execute_data)) {
return FAILURE;
@@ -1016,7 +1001,7 @@ SAPI_API zend_stat_t *sapi_get_stat(void)
}
}
-SAPI_API char *sapi_getenv(char *name, size_t name_len)
+SAPI_API char *sapi_getenv(const char *name, size_t name_len)
{
if (!strncasecmp(name, "HTTP_PROXY", name_len)) {
/* Ugly fix for HTTP_PROXY issue, see bug #72573 */
@@ -1103,10 +1088,10 @@ SAPI_API void sapi_terminate_process(void) {
}
}
-SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg) /* {{{ */
+SAPI_API void sapi_add_request_header(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg) /* {{{ */
{
zval *return_value = (zval*)arg;
- char *str = NULL;
+ char *buf = NULL;
ALLOCA_FLAG(use_heap)
@@ -1117,11 +1102,12 @@ SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val
var[3] == 'P' &&
var[4] == '_') {
- char *p;
+ const char *p;
+ char *str;
var_len -= 5;
p = var + 5;
- var = str = do_alloca(var_len + 1, use_heap);
+ var = str = buf = do_alloca(var_len + 1, use_heap);
*str++ = *p++;
while (*p) {
if (*p == '_') {
@@ -1147,8 +1133,8 @@ SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val
return;
}
add_assoc_stringl_ex(return_value, var, var_len, val, val_len);
- if (str) {
- free_alloca(var, use_heap);
+ if (buf) {
+ free_alloca(buf, use_heap);
}
}
/* }}} */