mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
MFH: call ap_set_content_type() only once, else each time we call it,
configured output filters for that content type will be added
This commit is contained in:
parent
1ad21d9b12
commit
d724f9cfb1
2 changed files with 15 additions and 6 deletions
|
@ -44,6 +44,8 @@ typedef struct php_struct {
|
||||||
#endif
|
#endif
|
||||||
/* Whether or not we've processed PHP in the output filters yet. */
|
/* Whether or not we've processed PHP in the output filters yet. */
|
||||||
int request_processed;
|
int request_processed;
|
||||||
|
/* final content type */
|
||||||
|
char *content_type;
|
||||||
} php_struct;
|
} php_struct;
|
||||||
|
|
||||||
void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf);
|
void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf);
|
||||||
|
|
|
@ -105,8 +105,10 @@ php_apache_sapi_header_handler(sapi_header_struct *sapi_header,sapi_headers_stru
|
||||||
} while (*val == ' ');
|
} while (*val == ' ');
|
||||||
|
|
||||||
if (!strcasecmp(sapi_header->header, "content-type")) {
|
if (!strcasecmp(sapi_header->header, "content-type")) {
|
||||||
val = apr_pstrdup(ctx->r->pool, val);
|
if (ctx->content_type) {
|
||||||
ap_set_content_type(ctx->r, val);
|
efree(ctx->content_type);
|
||||||
|
}
|
||||||
|
ctx->content_type = estrdup(val);
|
||||||
} else if (sapi_header->replace) {
|
} else if (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 {
|
||||||
|
@ -131,6 +133,15 @@ php_apache_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
|
||||||
&& sline[8] == ' ') {
|
&& sline[8] == ' ') {
|
||||||
ctx->r->status_line = apr_pstrdup(ctx->r->pool, sline + 9);
|
ctx->r->status_line = apr_pstrdup(ctx->r->pool, sline + 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* call ap_set_content_type only once, else each time we call it,
|
||||||
|
configured output filters for that content type will be added */
|
||||||
|
if (!ctx->content_type) {
|
||||||
|
ctx->content_type = sapi_get_default_content_type(TSRMLS_C);
|
||||||
|
}
|
||||||
|
ap_set_content_type(ctx->r, apr_pstrdup(ctx->r->pool, ctx->content_type));
|
||||||
|
efree(ctx->content_type);
|
||||||
|
ctx->content_type = NULL;
|
||||||
|
|
||||||
return SAPI_HEADER_SENT_SUCCESSFULLY;
|
return SAPI_HEADER_SENT_SUCCESSFULLY;
|
||||||
}
|
}
|
||||||
|
@ -418,10 +429,6 @@ static int php_apache_request_ctor(request_rec *r, php_struct *ctx TSRMLS_DC)
|
||||||
SG(request_info).path_translated = apr_pstrdup(r->pool, r->filename);
|
SG(request_info).path_translated = apr_pstrdup(r->pool, r->filename);
|
||||||
r->no_local_copy = 1;
|
r->no_local_copy = 1;
|
||||||
|
|
||||||
content_type = sapi_get_default_content_type(TSRMLS_C);
|
|
||||||
ap_set_content_type(r, apr_pstrdup(r->pool, content_type));
|
|
||||||
efree(content_type);
|
|
||||||
|
|
||||||
content_length = (char *) apr_table_get(r->headers_in, "Content-Length");
|
content_length = (char *) apr_table_get(r->headers_in, "Content-Length");
|
||||||
SG(request_info).content_length = (content_length ? atoi(content_length) : 0);
|
SG(request_info).content_length = (content_length ? atoi(content_length) : 0);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue