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

reset request body when proxy get request from fastify #12

Merged
merged 2 commits into from
May 28, 2018
Merged

reset request body when proxy get request from fastify #12

merged 2 commits into from
May 28, 2018

Conversation

vincent178
Copy link
Member

according to https://tools.ietf.org/html/rfc2616#section-4.3. fastify ignore message body when it's a GET request. when proxy this request, we should reset the content-length to make it a valid http request discussion: fastify/fastify#953

index.js Outdated
// when proxy this request, we should reset the content-length to make it a valid http request
// discussion: https://github.com/fastify/fastify/issues/953
if (req.method === 'GET') {
headers['content-length'] = Buffer.byteLength(body)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would reset it to zero. GETs do not have bodies, and we should not forward them.

@vincent178
Copy link
Member Author

Sure, my original thought is future compatibility if we want to use the body in some way. But I agree with you, we don't need think that way. I will change it.

@vincent178
Copy link
Member Author

updated @mcollina

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mcollina mcollina merged commit 6705d89 into fastify:master May 28, 2018
// fastify ignore message body when it's a GET request
// when proxy this request, we should reset the content-length to make it a valid http request
// discussion: https://github.com/fastify/fastify/issues/953
if (req.method === 'GET') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should do the same for HEAD requests.

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.

3 participants