derekelkins/sws

Override content-type header

Closed this issue · 1 comments

I would like to override the content type of some file.

sws --local --no-auth . --port 5443 --certificate=cert.pem --key-file=nopasskey.pem  -X 'Content-Type: text/html'

I have the same file code.html and callback which is the same file but without the .html in the end. To simulate an OIDC client I need to use that URL (I don't control it) so I did a cp code.html callback.
with the code.html the header is present twice.

curl --insecure -I https://localhost:5443/code.html
HTTP/2 200
date: Thu, 11 Oct 2018 09:25:47 GMT
server: Warp/3.2.13
last-modified: Tue, 24 Apr 2018 11:40:38 GMT
content-length: 9592
accept-ranges: bytes
content-type: text/html; charset=utf-8
content-type: text/html

with the callback file the header is also present and at the end of the list of headers.
So the browser ask me to download the file instead of displaying the result as an HTML page.

curl --insecure -I https://localhost:5443/callback
HTTP/2 200
date: Thu, 11 Oct 2018 09:34:32 GMT
server: Warp/3.2.13
last-modified: Thu, 11 Oct 2018 08:29:59 GMT
content-length: 9592
accept-ranges: bytes
content-type: text/html; charset=utf-8
content-type: application/octet-stream

This is more notes for myself. I'll look into doing something for this in a bit. I should be able to use http://hackage.haskell.org/package/wai-extra-3.0.24.3/docs/Network-Wai-Middleware-StripHeaders.html to first remove headers that will be added by addHeaders.

Thanks for pointing out the issue.