This repository was archived by the owner on Jan 8, 2024. It is now read-only.
Add content-length header where it is possible without reading buffers #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
Content-Lengthheader is missing for some JSON responses.After some investigation, I found the following comment in the net/http documentation that states that
This led to the conclusion that there is no
Content-Lengthheader for longer responses because they are longer than the 2048-byte limit. However, in a lot of cases, the renderer knows the length of the response (it's a[]byteorstring)This PR adds the
Content-Lengthheader in those cases.This investigation was because we noticed gzip compression in our CDN wasn't working (Cloudfront), and we realized this was due to the missing
Content-Lengthheader.https://aws.amazon.com/premiumsupport/knowledge-center/cloudfront-troubleshoot-compressed-files/#:~:text=Check%20your%20CloudFront%20configuration,a%20value%20greater%20than%20zero.
I have added test cases for the renderers with the added
Content-Lengthheader. There are some inconsistencies in the actual renderers and how the tests are structured, so I adapted my code to the style of the current scope.master