summaryrefslogtreecommitdiffstats
path: root/server/protocol.c
diff options
context:
space:
mode:
authorJim Jagielski <jim@apache.org>2013-09-19 17:30:10 +0200
committerJim Jagielski <jim@apache.org>2013-09-19 17:30:10 +0200
commit5e6a9dee07571756044fb1b6121237d6264fece9 (patch)
tree37753e8d10a11967af04b3a2e85ea8bea68a1e23 /server/protocol.c
parentUse apr_socket_timeout_get instead of hard-coded 30 seconds timeout. (diff)
downloadapache2-5e6a9dee07571756044fb1b6121237d6264fece9.tar.xz
apache2-5e6a9dee07571756044fb1b6121237d6264fece9.zip
draft-ietf-httpbis-p1-messaging-23 fixes regarding interactions
between TE and content-length in the same req/resp. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1524770 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--server/protocol.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/server/protocol.c b/server/protocol.c
index f011656b09..86be1b6dc0 100644
--- a/server/protocol.c
+++ b/server/protocol.c
@@ -1091,6 +1091,8 @@ request_rec *ap_read_request(conn_rec *conn)
}
if (!r->assbackwards) {
+ const char *tenc;
+
ap_get_mime_headers_core(r, tmp_bb);
if (r->status != HTTP_OK) {
ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(00567)
@@ -1102,13 +1104,33 @@ request_rec *ap_read_request(conn_rec *conn)
goto traceout;
}
- if (apr_table_get(r->headers_in, "Transfer-Encoding")
- && apr_table_get(r->headers_in, "Content-Length")) {
- /* http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-23#page-31
- * "If a message is received with both a Transfer-Encoding and a
- * Content-Length header field, the Transfer-Encoding overrides the
- * Content-Length. ... A sender MUST remove the received Content-
- * Length field"
+ tenc = apr_table_get(r->headers_in, "Transfer-Encoding");
+ if (tenc) {
+ /* http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-23
+ * Section 3.3.3.3: "If a Transfer-Encoding header field is
+ * present in a request and the chunked transfer coding is not
+ * the final encoding ...; the server MUST respond with the 400
+ * (Bad Request) status code and then close the connection".
+ */
+ if (!(strcasecmp(tenc, "chunked") == 0 /* fast path */
+ || ap_find_last_token(r->pool, tenc, "chunked"))) {
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO()
+ "client sent unknown Transfer-Encoding "
+ "(%s): %s", tenc, r->uri);
+ r->status = HTTP_BAD_REQUEST;
+ conn->keepalive = AP_CONN_CLOSE;
+ ap_send_error_response(r, 0);
+ ap_update_child_status(conn->sbh, SERVER_BUSY_LOG, r);
+ ap_run_log_transaction(r);
+ apr_brigade_destroy(tmp_bb);
+ goto traceout;
+ }
+
+ /* http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-23
+ * Section 3.3.3.3: "If a message is received with both a
+ * Transfer-Encoding and a Content-Length header field, the
+ * Transfer-Encoding overrides the Content-Length. ... A sender
+ * MUST remove the received Content-Length field".
*/
apr_table_unset(r->headers_in, "Content-Length");
}