Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tls + static files: Missing response header "content-encoding" #421

Closed
neowutran opened this issue Jul 25, 2018 · 9 comments
Closed

tls + static files: Missing response header "content-encoding" #421

neowutran opened this issue Jul 25, 2018 · 9 comments

Comments

@neowutran
Copy link

Hi,

When I am using TLS ( like https://github.com/actix/examples/blob/master/tls/src/main.rs#L44 ), I cannot use my browser to see the static files anymore ( only tested with static files )

The issue is that the header "content-encoding" is missing in the response header. So the browser receive correctly the compressed data, but doesn't know how to decompress them.

The error is linked with TLS / HTTP2

In my code, I have a

 bind_ssl("xxxxxxxx:yyyy", builder)

Header sended by the browser:

Host: neowutran.ovh:8083
User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Pragma: no-cache
Cache-Control: no-cache

Header received by the browser:

HTTP/2.0 200 OK
content-type: text/html
content-disposition: inline; filename="index.html"
last-modified: Fri, 20 Jul 2018 10:12:01 GMT
etag: "45b25:382:5b51b571:108ea573"
accept-ranges: bytes
date: Wed, 25 Jul 2018 11:57:30 GMT
X-Firefox-Spdy: h2

If I stop using TLS, replacing

 bind_ssl("xxxxxxxx:yyyy", builder)

by

.bind("xxxxxxxx:yyyy")

Then the header received by the browser is

 HTTP/1.1 200 OK
transfer-encoding: chunked
content-encoding: gzip
content-type: text/html
content-disposition: inline; filename="index.html"
last-modified: Fri, 20 Jul 2018 10:12:01 GMT
etag: "45b25:382:5b51b571:108ea573"
accept-ranges: bytes
date: Wed, 25 Jul 2018 12:40:34 GMT

"content-encoding" header seems to be missing in the response when using TLS / HTTP2

(All dependencies are up to date )

Thanks

@joncfoo
Copy link

joncfoo commented Jul 25, 2018

Tested this with actix-web v0.7.1 and can confirm that content-encoding is missing. Images don't load properly in Firefox and Chrome.

My current workaround is to disable HTTP2 via no_http2() on actix_web::server::HttpServer

Note: content-encoding appears to be missing for all [my] routes with tls+http2 as well - it's not just the StaticFiles handler.

@neowutran
Copy link
Author

Tested your workaround to disable HTTP2 via no_http2() -> content-encoding is back in the header, thanks

@fafhrd91
Copy link
Member

@neowutran fixed in master, could you try it

@joncfoo
Copy link

joncfoo commented Jul 25, 2018

@fafhrd91 thanks, the content-encoding header now shows up!

#290 still prevents usage of http2 for any moderately sized files though.

@fafhrd91
Copy link
Member

@joncfoo do you see same behavior as #290 ?

@joncfoo
Copy link

joncfoo commented Jul 25, 2018

@fafhrd91 yes I do (and I'm on linux)

@joncfoo
Copy link

joncfoo commented Jul 25, 2018

Happy to discuss this on gitter

@neowutran
Copy link
Author

Yup, content-encoding is back in master : )

@neowutran
Copy link
Author

& no issue like #290 with master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants