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

Webserver attempts to use chunked encoding even for HTTP/1.0 requests #350

Closed
nwf opened this issue Aug 31, 2020 · 6 comments
Closed

Webserver attempts to use chunked encoding even for HTTP/1.0 requests #350

nwf opened this issue Aug 31, 2020 · 6 comments
Labels

Comments

@nwf
Copy link

nwf commented Aug 31, 2020

Like it says in the title: the embedded mongoose server is wired to always send Transfer-Encoding: chunked even when the request is HTTP/1.0. This means that things almost work when ot-recorder is reverse-proxied behind lighttpd but the api endpoints get a 502 Bad Gateway.

Would it be possible to fall back to computing the entire response up front for HTTP/1.0 requests, or at least failing them with a more descriptive error message (e.g. 505 HTTP Version Not Supported)?

@jpmens
Copy link
Member

jpmens commented Sep 2, 2020

Thanks for your report. Am I understanding correctly that you're talking to ot-recorder with an HTTP/1.0 client and that you cannot make it speak 1.1?

That surprises me a bit as neither Apache nor nginx seem to have that problem, but I have not tried with lighttpd.

@nwf
Copy link
Author

nwf commented Sep 2, 2020

That's correct; until very recently (lighttpd/lighttpd1.4@f7919c1) lighttpd always sent HTTP/1.0 requests to its proxy backends and couldn't parse Transfer-Encoding: chunked replies.

After noticing that patch, tho', and jumping up to HEAD on my webserver, I now observe that ot-recorder is emitting both Transfer-Encoding: chunked and Content-Length response headers (itself a kind of bogus outcome) and the Content-Length is wrong (much more bogus; it is, in particular, much too short) when replying from the last api endpoint. I had to teach lighttpd to squash that header from responses, and then magically things worked.

@jpmens jpmens added the bug label Sep 3, 2020
@jpmens
Copy link
Member

jpmens commented Sep 3, 2020

I believe we fixed the too short Content-Length header in 31f453c (the commit message inaccurately says "Safari only")

@jpmens
Copy link
Member

jpmens commented Sep 8, 2020

Thank you for your report and help, @nwf. We're replacing the illegal Content-Length header by X-Content-Length where it might be used by our Frontend.

Before:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 469
Transfer-Encoding: chunked

After:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
X-Content-Length: 469
Transfer-Encoding: chunked

@jpmens jpmens closed this as completed in 3d18bf8 Sep 8, 2020
@nwf
Copy link
Author

nwf commented Sep 9, 2020

Thank you for the heads up, but I believe that the initial bug -- that the server speaks HTTP/1.1 in response to a HTTP/1.0 request -- still stands?

@jpmens
Copy link
Member

jpmens commented Sep 9, 2020

Yes, that's part of the embedded mongoose server, and we cannot easily change that.

jpmens added a commit that referenced this issue Jun 29, 2021
- UPD: Leaflet GeoJSON map point popups now contain accuracy if available (#352)
- FIX: prefix Content-Length by X- to avoid issues with chunked encoding #350
- FIX: fix off-by-one error introduced in #328 (Safari only)
wollew pushed a commit to wollew/recorder that referenced this issue Feb 2, 2022
wollew pushed a commit to wollew/recorder that referenced this issue Feb 2, 2022
- UPD: Leaflet GeoJSON map point popups now contain accuracy if available (owntracks#352)
- FIX: prefix Content-Length by X- to avoid issues with chunked encoding owntracks#350
- FIX: fix off-by-one error introduced in owntracks#328 (Safari only)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants