Welcome! Log In Create A New Profile

Advanced

Content-Type with charset

Matthieu Tourne
October 25, 2010 08:36PM
Hello,

I have a case where the origin server behind nginx returns this header:
Content-Type: application/javascript; charset: UTF-8

Which seems to be valid according for HTTP/1.0 [1] and HTTP/1.1 [2] rfcs.

I have gzip_types set to application/javascript, but the added charset
part seems to throw off ngx_http_test_content_type()

This simple patch included below seems to fix it, but it's not exactly
production ready.

Is there another way to make this work ?

Thank you,

Matthieu.


[1] http://www.ietf.org/rfc/rfc1945.txt
[2] http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html


----------------------- PATCH -------------------------

--- tmp/tmpHfGmfb-meld/src/http/ngx_http_core_module.c
+++ home/mtourne/Dev/nginx/src/http/ngx_http_core_module.c
@@ -1652,11 +1659,15 @@
hash = 0;

for (i = 0; i < len; i++) {
+ if (r->headers_out.content_type.data[i] == ';') {
+ break;
+ }
c = ngx_tolower(r->headers_out.content_type.data[i]);
hash = ngx_hash(hash, c);
lowcase[i] = c;
}

+ len = r->headers_out.content_type_len = i;
r->headers_out.content_type_hash = hash;
}


--
Matthieu Tourne

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Content-Type with charset

Matthieu Tourne October 25, 2010 08:36PM

Re: Content-Type with charset

Maxim Dounin October 26, 2010 04:06AM

Re: Content-Type with charset

SplitIce October 26, 2010 04:14AM

Re: Content-Type with charset

Maxim Dounin October 26, 2010 12:38PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 126
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready