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

Remove Content-Length from HTTP Connect Custom response #29

Merged

Conversation

saurabhbhatia-stripe
Copy link

@saurabhbhatia-stripe saurabhbhatia-stripe commented Oct 22, 2024

Summary

Currently while using HTTP Connect custom handlers it responds with content-length as 0 along with HTTP/1.0 200 OK. This is not RFC-9110 compliant which states that a server MUST NOT send any Transfer-Encoding or Content-Length header fields in a 2xx (Successful) response to CONNECT.

Old HTTP Connect Custom Response

HTTP/1.0 200 OK
Content-Length: 0

New HTTP Connect Custom Response

HTTP/1.0 200 OK

Changes

We are setting ContentLength as -1 which marks it as unknown and removes content length while writing response

Snippet from Response Struct

// ContentLength records the length of the associated content. The
// value -1 indicates that the length is unknown. Unless Request.Method
// is "HEAD", values >= 0 indicate that the given number of bytes may
// be read from Body.
ContentLength int64

@saurabhbhatia-stripe saurabhbhatia-stripe merged commit 5811784 into master Oct 22, 2024
5 checks passed
@saurabhbhatia-stripe saurabhbhatia-stripe deleted the saurabhbhatia/fix-custom-connect-response branch October 22, 2024 13:14
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