mirror of
https://github.com/php/php-src.git
synced 2025-08-18 06:58:55 +02:00
Updated header_handler in apache2filter and apache_hooks
This commit is contained in:
parent
494dbdb1c1
commit
aaaf67e19e
2 changed files with 78 additions and 44 deletions
|
@ -91,7 +91,7 @@ php_apache_sapi_ub_write(const char *str, uint str_length TSRMLS_DC)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC)
|
php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers TSRMLS_DC)
|
||||||
{
|
{
|
||||||
php_struct *ctx;
|
php_struct *ctx;
|
||||||
ap_filter_t *f;
|
ap_filter_t *f;
|
||||||
|
@ -100,6 +100,17 @@ php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_str
|
||||||
ctx = SG(server_context);
|
ctx = SG(server_context);
|
||||||
f = ctx->r->output_filters;
|
f = ctx->r->output_filters;
|
||||||
|
|
||||||
|
switch(op) {
|
||||||
|
case SAPI_HEADER_DELETE:
|
||||||
|
apr_table_unset(ctx->r->headers_out, sapi_header->header);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case SAPI_HEADER_DELETE_ALL:
|
||||||
|
apr_table_clear(ctx->r->headers_out);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case SAPI_HEADER_ADD:
|
||||||
|
case SAPI_HEADER_REPLACE:
|
||||||
val = strchr(sapi_header->header, ':');
|
val = strchr(sapi_header->header, ':');
|
||||||
|
|
||||||
if (!val) {
|
if (!val) {
|
||||||
|
@ -116,13 +127,17 @@ php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_str
|
||||||
|
|
||||||
if (!strcasecmp(sapi_header->header, "content-type"))
|
if (!strcasecmp(sapi_header->header, "content-type"))
|
||||||
ctx->r->content_type = apr_pstrdup(ctx->r->pool, val);
|
ctx->r->content_type = apr_pstrdup(ctx->r->pool, val);
|
||||||
else if (sapi_header->replace)
|
else if (op == SAPI_HEADER_REPLACE)
|
||||||
apr_table_set(ctx->r->headers_out, sapi_header->header, val);
|
apr_table_set(ctx->r->headers_out, sapi_header->header, val);
|
||||||
else
|
else
|
||||||
apr_table_add(ctx->r->headers_out, sapi_header->header, val);
|
apr_table_add(ctx->r->headers_out, sapi_header->header, val);
|
||||||
|
|
||||||
*ptr = ':';
|
*ptr = ':';
|
||||||
return SAPI_HEADER_ADD;
|
return SAPI_HEADER_ADD;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -34,7 +34,7 @@ static void php_save_umask(void);
|
||||||
static void php_restore_umask(void);
|
static void php_restore_umask(void);
|
||||||
static int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC);
|
static int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC);
|
||||||
static char *sapi_apache_read_cookies(TSRMLS_D);
|
static char *sapi_apache_read_cookies(TSRMLS_D);
|
||||||
static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC);
|
static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers TSRMLS_DC);
|
||||||
static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC);
|
static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC);
|
||||||
static int send_php(request_rec *r, int display_source_mode, char *filename);
|
static int send_php(request_rec *r, int display_source_mode, char *filename);
|
||||||
static int send_parsed_php(request_rec * r);
|
static int send_parsed_php(request_rec * r);
|
||||||
|
@ -308,16 +308,29 @@ static char *sapi_apache_read_cookies(TSRMLS_D)
|
||||||
|
|
||||||
/* {{{ sapi_apache_header_handler
|
/* {{{ sapi_apache_header_handler
|
||||||
*/
|
*/
|
||||||
static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC)
|
static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers TSRMLS_DC)
|
||||||
{
|
{
|
||||||
char *header_name, *header_content, *p;
|
char *header_name, *header_content, *p;
|
||||||
request_rec *r = (request_rec *) SG(server_context);
|
request_rec *r = (request_rec *) SG(server_context);
|
||||||
|
if(!r) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(op) {
|
||||||
|
case SAPI_HEADER_DELETE_ALL:
|
||||||
|
clear_table(r->headers_out);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case SAPI_HEADER_DELETE:
|
||||||
|
table_unset(r->headers_out, sapi_header->header);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case SAPI_HEADER_ADD:
|
||||||
|
case SAPI_HEADER_REPLACE:
|
||||||
header_name = sapi_header->header;
|
header_name = sapi_header->header;
|
||||||
|
|
||||||
header_content = p = strchr(header_name, ':');
|
header_content = p = strchr(header_name, ':');
|
||||||
if (!p) {
|
if (!p) {
|
||||||
efree(sapi_header->header);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,13 +343,19 @@ static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_head
|
||||||
r->content_type = pstrdup(r->pool, header_content);
|
r->content_type = pstrdup(r->pool, header_content);
|
||||||
} else if (!strcasecmp(header_name, "Set-Cookie")) {
|
} else if (!strcasecmp(header_name, "Set-Cookie")) {
|
||||||
table_add(r->headers_out, header_name, header_content);
|
table_add(r->headers_out, header_name, header_content);
|
||||||
} else {
|
} else if (op == SAPI_HEADER_REPLACE) {
|
||||||
table_set(r->headers_out, header_name, header_content);
|
table_set(r->headers_out, header_name, header_content);
|
||||||
|
} else {
|
||||||
|
table_add(r->headers_out, header_name, header_content);
|
||||||
}
|
}
|
||||||
|
|
||||||
*p = ':'; /* a well behaved header handler shouldn't change its original arguments */
|
*p = ':'; /* a well behaved header handler shouldn't change its original arguments */
|
||||||
|
|
||||||
return SAPI_HEADER_ADD;
|
return SAPI_HEADER_ADD;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue