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

Fix JSON parse error when backend returns 304 #56

Merged
merged 2 commits into from
Aug 5, 2021

Conversation

OttoWinter
Copy link
Member

For some URLs (namely /ping and /serial-ports) tornado will automatically set an ETag Header with the hashed payload.

When there's a cache hit, the backend only returns 304 Not Modified.

HTTP Request/response:

GET /serial-ports HTTP/1.1
Host: localhost:6052
# ...
If-None-Match: "49b6fc370dd17e5696abd7a3294d834fac2cccd5"
Cache-Control: max-age=0


HTTP/1.1 304 Not Modified
Server: TornadoServer/6.1
Date: Thu, 05 Aug 2021 16:40:49 GMT
Etag: "49b6fc370dd17e5696abd7a3294d834fac2cccd5"

Importantly, for 304 Not Modified the content-type header is not sent (the HTTP RFC also specifies 304 to act just like that https://stackoverflow.com/a/31107285)

I know it's an ugly fix, but I couldn't find a way to disable the behavior in the backend (tornado has horrible docs). So instead fix it in the frontend (where ideally it should be fixed anyway, because the HTTP RFC recommends this behavior)

@OttoWinter OttoWinter merged commit 5bea25c into main Aug 5, 2021
@OttoWinter OttoWinter deleted the fix-304-missing-content-type branch August 5, 2021 17:22
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

Successfully merging this pull request may close these issues.

2 participants