开发者

Duplicate Content-Type headers in Nginx for CSV files

开发者 https://www.devze.com 2023-02-18 20:36 出处:网络
I have some .csv files that I\'m serving via Nginx straight from the filesystem. It currently looks like this::

I have some .csv files that I'm serving via Nginx straight from the filesystem. It currently looks like this::

location ~ /static/csv_exports/ {
        add_header Content-Type text/csv;
}

For some reason I had to do that because otherwise it would be served as text/plain. Here's what I get when I do a curl on it:

$ curl -v http://localhost/static/csv_exports/20110322_172651.csv >> /dev/null
...
 < HTTP/1.1 200 OK
 < Server: nginx/0.7.67
 < Date: Tue, 22 Mar 2011 17开发者_JAVA技巧:32:07 GMT
 < Content-Type: text/plain
 < Content-Length: 356623
 < Last-Modified: Tue, 22 Mar 2011 17:26:52 GMT
 < Connection: keep-alive
 < Cache-Control: public
 < Content-Type: text/csv
 < Accept-Ranges: bytes

See! It's got two "Content-Type" headers. Opening it in the browser automatically opens Open Office and it works just fine but I suspect I haven't done it right.


location ~ /static/csv_exports/ {
-    add_header Content-Type text/csv;
+    types {text/csv csv;}
}
0

精彩评论

暂无评论...
验证码 换一张
取 消