[PATCH] HTTP Strip Content-Type by semicolon

Maxim Muzafarov m.muzafarov at gmail.com
Tue Dec 22 11:24:18 UTC 2015


Of course, I mean "application/json; charset=UTF-8". 
In working copy this content-type needed to be declared separately, which may be difficult, when content-type received from backend.

> On 22 Dec 2015, at 14:12, Maxim Muzafarov <m.muzafarov at gmail.com> wrote:
> 
> # HG changeset patch
> # User Maxim Muzafarov <m.muzafarov at gmail.com>
> # Date 1450782516 -10800
> #      Tue Dec 22 14:08:36 2015 +0300
> # Node ID efdf809163976307021556c3a11a4b66201c1375
> # Parent  78b4e10b4367b31367aad3c83c9c3acdd42397c4
> Strip Content-Type by semicolon
> 
> Test only first part of Content-Type in heavy mimes, such as "applciation/json; encoding=UTF-8" Useful for gzip_types hash, for example.
> 
> diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
> --- a/src/http/ngx_http_core_module.c
> +++ b/src/http/ngx_http_core_module.c
> @@ -1679,6 +1679,10 @@
> 
>         for (i = 0; i < len; i++) {
>             c = ngx_tolower(r->headers_out.content_type.data[i]);
> +            if (c == ';') {
> +                len = i;
> +                break;
> +            }
>             hash = ngx_hash(hash, c);
>             lowcase[i] = c;
>         }
> 



More information about the nginx-devel mailing list