mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
let httpd handle CL/TE for non-http handlers
Submitted By: ylavic, covener git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1916769 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -265,6 +265,8 @@ AP_DECLARE(int) ap_scan_script_header_err_core_ex(request_rec *r, char *buffer,
|
|||||||
*/
|
*/
|
||||||
AP_DECLARE(void) ap_args_to_table(request_rec *r, apr_table_t **table);
|
AP_DECLARE(void) ap_args_to_table(request_rec *r, apr_table_t **table);
|
||||||
|
|
||||||
|
#define AP_TRUST_CGILIKE_CL_ENVVAR "ap_trust_cgilike_cl"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -570,6 +570,14 @@ static apr_status_t handle_response(const fcgi_provider_conf *conf,
|
|||||||
"parsing -> %d/%d",
|
"parsing -> %d/%d",
|
||||||
fn, status, r->status);
|
fn, status, r->status);
|
||||||
|
|
||||||
|
/* FCGI has its own body framing mechanism which we don't
|
||||||
|
* match against any provided Content-Length, so let the
|
||||||
|
* core determine C-L vs T-E based on what's actually sent.
|
||||||
|
*/
|
||||||
|
if (!apr_table_get(r->subprocess_env, AP_TRUST_CGILIKE_CL_ENVVAR))
|
||||||
|
apr_table_unset(r->headers_out, "Content-Length");
|
||||||
|
apr_table_unset(r->headers_out, "Transfer-Encoding");
|
||||||
|
|
||||||
if (rspbuf) { /* caller wants to see response body,
|
if (rspbuf) { /* caller wants to see response body,
|
||||||
* if any
|
* if any
|
||||||
*/
|
*/
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "httpd.h"
|
#include "httpd.h"
|
||||||
#include "util_filter.h"
|
#include "util_filter.h"
|
||||||
|
#include "util_script.h"
|
||||||
|
|
||||||
static APR_OPTIONAL_FN_TYPE(ap_ssi_get_tag_and_value) *cgi_pfn_gtv;
|
static APR_OPTIONAL_FN_TYPE(ap_ssi_get_tag_and_value) *cgi_pfn_gtv;
|
||||||
static APR_OPTIONAL_FN_TYPE(ap_ssi_parse_string) *cgi_pfn_ps;
|
static APR_OPTIONAL_FN_TYPE(ap_ssi_parse_string) *cgi_pfn_ps;
|
||||||
@@ -428,9 +429,18 @@ static int cgi_handle_response(request_rec *r, int nph, apr_bucket_brigade *bb,
|
|||||||
char sbuf[MAX_STRING_LEN];
|
char sbuf[MAX_STRING_LEN];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if ((ret = ap_scan_script_header_err_brigade_ex(r, bb, sbuf,
|
ret = ap_scan_script_header_err_brigade_ex(r, bb, sbuf,
|
||||||
APLOG_MODULE_INDEX)))
|
APLOG_MODULE_INDEX);
|
||||||
{
|
|
||||||
|
/* xCGI has its own body framing mechanism which we don't
|
||||||
|
* match against any provided Content-Length, so let the
|
||||||
|
* core determine C-L vs T-E based on what's actually sent.
|
||||||
|
*/
|
||||||
|
if (!apr_table_get(r->subprocess_env, AP_TRUST_CGILIKE_CL_ENVVAR))
|
||||||
|
apr_table_unset(r->headers_out, "Content-Length");
|
||||||
|
apr_table_unset(r->headers_out, "Transfer-Encoding");
|
||||||
|
|
||||||
|
if (ret != OK) {
|
||||||
/* In the case of a timeout reading script output, clear
|
/* In the case of a timeout reading script output, clear
|
||||||
* the brigade to avoid a second attempt to read the
|
* the brigade to avoid a second attempt to read the
|
||||||
* output. */
|
* output. */
|
||||||
|
@@ -810,6 +810,18 @@ static APR_INLINE int check_headers(request_rec *r)
|
|||||||
struct check_header_ctx ctx;
|
struct check_header_ctx ctx;
|
||||||
core_server_config *conf =
|
core_server_config *conf =
|
||||||
ap_get_core_module_config(r->server->module_config);
|
ap_get_core_module_config(r->server->module_config);
|
||||||
|
const char *val;
|
||||||
|
|
||||||
|
if ((val = apr_table_get(r->headers_out, "Transfer-Encoding"))) {
|
||||||
|
if (apr_table_get(r->headers_out, "Content-Length")) {
|
||||||
|
apr_table_unset(r->headers_out, "Content-Length");
|
||||||
|
r->connection->keepalive = AP_CONN_CLOSE;
|
||||||
|
}
|
||||||
|
if (!ap_is_chunked(r->pool, val)) {
|
||||||
|
r->connection->keepalive = AP_CONN_CLOSE;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ctx.r = r;
|
ctx.r = r;
|
||||||
ctx.strict = (conf->http_conformance != AP_HTTP_CONFORMANCE_UNSAFE);
|
ctx.strict = (conf->http_conformance != AP_HTTP_CONFORMANCE_UNSAFE);
|
||||||
|
@@ -17,6 +17,8 @@
|
|||||||
#include "ajp_header.h"
|
#include "ajp_header.h"
|
||||||
#include "ajp.h"
|
#include "ajp.h"
|
||||||
|
|
||||||
|
#include "util_script.h"
|
||||||
|
|
||||||
APLOG_USE_MODULE(proxy_ajp);
|
APLOG_USE_MODULE(proxy_ajp);
|
||||||
|
|
||||||
static const char *response_trans_headers[] = {
|
static const char *response_trans_headers[] = {
|
||||||
@@ -669,6 +671,14 @@ static apr_status_t ajp_unmarshal_response(ajp_msg_t *msg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* AJP has its own body framing mechanism which we don't
|
||||||
|
* match against any provided Content-Length, so let the
|
||||||
|
* core determine C-L vs T-E based on what's actually sent.
|
||||||
|
*/
|
||||||
|
if (!apr_table_get(r->subprocess_env, AP_TRUST_CGILIKE_CL_ENVVAR))
|
||||||
|
apr_table_unset(r->headers_out, "Content-Length");
|
||||||
|
apr_table_unset(r->headers_out, "Transfer-Encoding");
|
||||||
|
|
||||||
return APR_SUCCESS;
|
return APR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -779,6 +779,15 @@ recv_again:
|
|||||||
|
|
||||||
status = ap_scan_script_header_err_brigade_ex(r, ob,
|
status = ap_scan_script_header_err_brigade_ex(r, ob,
|
||||||
NULL, APLOG_MODULE_INDEX);
|
NULL, APLOG_MODULE_INDEX);
|
||||||
|
|
||||||
|
/* FCGI has its own body framing mechanism which we don't
|
||||||
|
* match against any provided Content-Length, so let the
|
||||||
|
* core determine C-L vs T-E based on what's actually sent.
|
||||||
|
*/
|
||||||
|
if (!apr_table_get(r->subprocess_env, AP_TRUST_CGILIKE_CL_ENVVAR))
|
||||||
|
apr_table_unset(r->headers_out, "Content-Length");
|
||||||
|
apr_table_unset(r->headers_out, "Transfer-Encoding");
|
||||||
|
|
||||||
/* suck in all the rest */
|
/* suck in all the rest */
|
||||||
if (status != OK) {
|
if (status != OK) {
|
||||||
apr_bucket *tmp_b;
|
apr_bucket *tmp_b;
|
||||||
|
@@ -390,6 +390,14 @@ static int pass_response(request_rec *r, proxy_conn_rec *conn)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* SCGI has its own body framing mechanism which we don't
|
||||||
|
* match against any provided Content-Length, so let the
|
||||||
|
* core determine C-L vs T-E based on what's actually sent.
|
||||||
|
*/
|
||||||
|
if (!apr_table_get(r->subprocess_env, AP_TRUST_CGILIKE_CL_ENVVAR))
|
||||||
|
apr_table_unset(r->headers_out, "Content-Length");
|
||||||
|
apr_table_unset(r->headers_out, "Transfer-Encoding");
|
||||||
|
|
||||||
conf = ap_get_module_config(r->per_dir_config, &proxy_scgi_module);
|
conf = ap_get_module_config(r->per_dir_config, &proxy_scgi_module);
|
||||||
if (conf->sendfile && conf->sendfile != scgi_sendfile_off) {
|
if (conf->sendfile && conf->sendfile != scgi_sendfile_off) {
|
||||||
short err = 1;
|
short err = 1;
|
||||||
|
@@ -404,6 +404,12 @@ static int uwsgi_response(request_rec *r, proxy_conn_rec * backend,
|
|||||||
return HTTP_BAD_GATEWAY;
|
return HTTP_BAD_GATEWAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* T-E wins over C-L */
|
||||||
|
if (apr_table_get(r->headers_out, "Transfer-Encoding")) {
|
||||||
|
apr_table_unset(r->headers_out, "Content-Length");
|
||||||
|
backend->close = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if ((buf = apr_table_get(r->headers_out, "Content-Type"))) {
|
if ((buf = apr_table_get(r->headers_out, "Content-Type"))) {
|
||||||
ap_set_content_type(r, apr_pstrdup(r->pool, buf));
|
ap_set_content_type(r, apr_pstrdup(r->pool, buf));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user