Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

CONNECT method should not have request body #637

Merged
merged 3 commits into from
Oct 30, 2018

Conversation

norio-nomura
Copy link
Contributor

CONNECT method should not have request body.

Motivation:

rfc7231 said:

A payload within a CONNECT request message has no defined semantics;
sending a payload body on a CONNECT request might cause some existing
implementations to reject the request.

Modifications:

Change HTTPMethod.CONNECT.hasRequestBody to returns .no.

Result:

HTTPRequestEncoder does not generate chunked body for CONNECT method.

### Motivation:

[rfc7231](https://tools.ietf.org/html/rfc7231#section-4.3.6) said:
> A payload within a `CONNECT` request message has no defined semantics;
   sending a payload body on a `CONNECT` request might cause some existing
   implementations to reject the request.

### Modifications:

Change `HTTPMethod.CONNECT.hasRequestBody` to returns `.no`.

### Result:

`HTTPRequestEncoder` does not generate chunked body for `CONNECT` method.
@swift-nio-bot
Copy link

Can one of the admins verify this patch?

2 similar comments
@swift-nio-bot
Copy link

Can one of the admins verify this patch?

@swift-nio-bot
Copy link

Can one of the admins verify this patch?

@Lukasa
Copy link
Contributor

Lukasa commented Oct 21, 2018

Thanks for this patch!

Sadly I wonder if perhaps we may need to fix this implementation a bit more. When RFC 7231 says “a payload has no defined semantics”, that is not the same as saying it may not be there. GET, for example, uses the same wording.

So I think this enum is wrong for a number of methods, and many of them should go into .unlikely instead of .no.

@Lukasa
Copy link
Contributor

Lukasa commented Oct 21, 2018

It would also be really good to add a regression test for the CONNECT change to validate that it continues to work in future.

@norio-nomura
Copy link
Contributor Author

norio-nomura commented Oct 21, 2018

So I think this enum is wrong for a number of methods, and many of them should go into .unlikely instead of .no.

Changed to .no.

It would also be really good to add a regression test for the CONNECT change to validate that it continues to work in future.

Is HTTPRequestEncoderTests.testCONNECT() not enough?
If hasRequestBody returns .yes, the request contains transfer-encoding: chunked\r\n\r\n0 without writing HTTPClientRequestPart.body to HTTPRequestEncoder.

Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

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

Cool, this looks good to me! Sorry for the note about testing, that’s what happens when I review on my phone.

@Lukasa
Copy link
Contributor

Lukasa commented Oct 21, 2018

@swift-nio-bot test this please

@Lukasa Lukasa added the 🔨 semver/patch No public API change. label Oct 21, 2018
@Lukasa Lukasa added this to the 1.10.0 milestone Oct 21, 2018
@Lukasa Lukasa modified the milestones: 1.10.0, 1.11.0 Oct 29, 2018
Copy link
Member

@weissi weissi left a comment

Choose a reason for hiding this comment

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

thank you!

@weissi
Copy link
Member

weissi commented Oct 30, 2018

@swift-nio-bot test this please

@weissi weissi merged commit 287d50c into apple:master Oct 30, 2018
@norio-nomura
Copy link
Contributor Author

Thanks! 🙏

@norio-nomura norio-nomura deleted the connect-has-no-request-body branch October 30, 2018 08:11
Copy link
Member

@normanmaurer normanmaurer left a comment

Choose a reason for hiding this comment

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

late LGTM

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants