Could this be backported please ?

The corresponding 2.4.x patch is attached...

Regards,
 Yann.



On Thu, Sep 19, 2013 at 5:30 PM, <j...@apache.org> wrote:

> Author: jim
> Date: Thu Sep 19 15:30:10 2013
> New Revision: 1524770
>
> URL: http://svn.apache.org/r1524770
> Log:
> draft-ietf-httpbis-p1-messaging-23 fixes regarding interactions
> between TE and content-length in the same req/resp.
>
> Modified:
>     httpd/httpd/trunk/CHANGES
>     httpd/httpd/trunk/modules/http/http_filters.c
>     httpd/httpd/trunk/server/protocol.c
>
> Modified: httpd/httpd/trunk/CHANGES
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1524770&r1=1524769&r2=1524770&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/CHANGES [utf-8] (original)
> +++ httpd/httpd/trunk/CHANGES [utf-8] Thu Sep 19 15:30:10 2013
> @@ -1,6 +1,9 @@
>                                                           -*- coding:
> utf-8 -*-
>  Changes with Apache 2.5.0
>
> +  *) core: draft-ietf-httpbis-p1-messaging-23 corrections regarding
> +     TE/CL conflicts. [Yann Ylavic <ylavic.dev gmail com>, Jim Jagielski]
> +
>    *) mod_proxy_fcgi: Use apr_socket_timeout_get instead of hard-coded
>       30 seconds timeout. [Jan Kaluza]
>
>
> Modified: httpd/httpd/trunk/modules/http/http_filters.c
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/http/http_filters.c?rev=1524770&r1=1524769&r2=1524770&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/modules/http/http_filters.c (original)
> +++ httpd/httpd/trunk/modules/http/http_filters.c Thu Sep 19 15:30:10 2013
> @@ -224,25 +224,32 @@ apr_status_t ap_http_filter(ap_filter_t
>          lenp = apr_table_get(f->r->headers_in, "Content-Length");
>
>          if (tenc) {
> -            if (!strcasecmp(tenc, "chunked")) {
> +            if (strcasecmp(tenc, "chunked") == 0 /* fast path */
> +                    || ap_find_last_token(f->r->pool, 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.
> +            else if (f->r->proxyreq == PROXYREQ_RESPONSE) {
> +                /*
> 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 response and the chunked transfer coding
> is not
> +                 * the final encoding, the message body length is
> determined by
> +                 * reading the connection until it is closed by the
> server."
>                   */
>                  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)
> "Unknown Transfer-Encoding: %s; using read-until-close", tenc);
> +                tenc = NULL;
>              }
>              else {
> +                /* Something that isn't a HTTP request, unless some future
> +                 * edition defines new transfer encodings, is unsupported.
> +                 */
>                  ap_log_rerror(
> -                        APLOG_MARK, APLOG_WARNING, 0, f->r,
> APLOGNO(01586) "Unknown Transfer-Encoding: %s; using Content-Length", tenc);
> -                tenc = NULL;
> +                        APLOG_MARK, APLOG_INFO, 0, f->r, APLOGNO(01585)
> "Unknown Transfer-Encoding: %s", tenc);
> +                return APR_EGENERAL;
>              }
> +            lenp = NULL;
>          }
> -        if (lenp && !tenc) {
> +        if (lenp) {
>              char *endstr;
>
>              ctx->state = BODY_LENGTH;
>
> Modified: httpd/httpd/trunk/server/protocol.c
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/server/protocol.c?rev=1524770&r1=1524769&r2=1524770&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/server/protocol.c (original)
> +++ httpd/httpd/trunk/server/protocol.c Thu Sep 19 15:30:10 2013
> @@ -1091,6 +1091,8 @@ request_rec *ap_read_request(conn_rec *c
>      }
>
>      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 *c
>              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");
>          }
>
>
>

Attachment: httpd-2.4.x-draft-ietf-httpbis-p1-messaging-23-3.3.3.3.patch
Description: Binary data

Reply via email to