if (!strcasecmp(tenc, "chunked")) {
ctx->state = BODY_CHUNK;
}
- /* test lenp, because it gives another case we can handle */
- else if (!lenp) {
- /* Something that isn't in HTTP, unless some future
- * edition defines new transfer encodings, is unsupported.
- */
+ /* RFC 2616 Section 4.4 states that if the message does
+ * include a non-identity transfer-coding, the Content-Length
+ * MUST be ignored.
+ */
+ else if (lenp) {
ap_log_rerror(
- APLOG_MARK, APLOG_INFO, 0, f->r, APLOGNO(01585) "Unknown Transfer-Encoding: %s", tenc);
- return APR_ENOTIMPL;
+ APLOG_MARK, APLOG_INFO, 0, f->r,
+ APLOGNO(01586) "Identity or Unknown Transfer-Encoding (%s); using Content-Length", tenc);
+ tenc = NULL;
}
else {
- ap_log_rerror(
- APLOG_MARK, APLOG_WARNING, 0, f->r, APLOGNO(01586) "Unknown Transfer-Encoding: %s; using Content-Length", tenc);
- tenc = NULL;
+ /* Something that isn't in HTTP, unless some future
+ * edition defines new transfer encodings, is unsupported.
+ */
+ ap_log_rerror(
+ APLOG_MARK, APLOG_INFO, 0, f->r,
+ APLOGNO(01585) "Unknown Transfer-Encoding: %s", tenc);
+ return APR_ENOTIMPL;
}
}
if (lenp && !tenc) {
}
if (!r->assbackwards) {
+ const char *tenc, *clen;
+
ap_get_mime_headers_core(r, tmp_bb);
if (r->status != HTTP_OK) {
ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(00567)
goto traceout;
}
- if (apr_table_get(r->headers_in, "Transfer-Encoding")
- && apr_table_get(r->headers_in, "Content-Length")) {
+ if ((tenc = apr_table_get(r->headers_in, "Transfer-Encoding"))) {
/* 2616 section 4.4, point 3: "if both Transfer-Encoding
* and Content-Length are received, the latter MUST be
- * ignored"; so unset it here to prevent any confusion
- * later. */
- apr_table_unset(r->headers_in, "Content-Length");
+ * ignored"; unless the former is "identity". So unset
+ * the one concerned here to prevent any confusion later.
+ */
+ if ((clen = apr_table_get(r->headers_in, "Content-Length"))) {
+ if (strcasecmp(tenc, "chunked") == 0) {
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(2537)
+ "client sent both Transfer-Encoding (chunked)"
+ " and Content-Length; using TE");
+ apr_table_unset(r->headers_in, "Content-Length");
+ }
+ else {
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(2538)
+ "client sent identity or unknown Transfer-Encoding (%s);"
+ " using Content-Length", tenc);
+ apr_table_unset(r->headers_in, "Transfer-Encoding");
+ }
+ }
+ else if (strcasecmp(tenc, "chunked") != 0) {
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(2539)
+ "client sent unknown Transfer-Encoding;"
+ " not implemented: %s", tenc);
+ r->status = HTTP_NOT_IMPLEMENTED;
+ 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;
+ }
}
}
else {