cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
- if (r->method == NGX_HTTP_CONNECT
- && (r->http_version != NGX_HTTP_VERSION_11 || !cscf->allow_connect))
- {
- ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
- "client sent CONNECT method");
- ngx_http_finalize_request(r, NGX_HTTP_NOT_ALLOWED);
- return NGX_ERROR;
+ if (r->method == NGX_HTTP_CONNECT) {
+ if (r->http_version != NGX_HTTP_VERSION_11 || !cscf->allow_connect) {
+ ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
+ "client sent CONNECT method");
+ ngx_http_finalize_request(r, NGX_HTTP_NOT_ALLOWED);
+ return NGX_ERROR;
+ }
+
+ if (r->headers_in.content_length_n > 0 || r->headers_in.chunked) {
+ ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
+ "client sent CONNECT request with body");
+ ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+ return NGX_ERROR;
+ }
}
if (r->method == NGX_HTTP_TRACE) {