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

Migrate http1 proxy connect handler #185

Merged
merged 13 commits into from
Jan 12, 2023

Conversation

rnro
Copy link
Contributor

@rnro rnro commented Nov 30, 2022

Motivation:

Moving the HTTP1ProxyConnectHandler into swift-nio-extras will make the
code which is generally useful when dealing with HTTP1 proxies available
more easily to a wider audience.

Modifications:

The code and tests are copied over from https://github.com/swift-server/async-http-client/blob/0b5bec741bfcf941e208d937de2ec29affe750a7/Sources/AsyncHTTPClient/ConnectionPool/ChannelHandler/HTTP1ProxyConnectHandler.swift.

The code is slightly modified to allow the specification of arbitrary headers rather than authorisation information.

Result:

HTTP1ProxyConnectHandler will be surfaced via the NIOExtras library

@swift-server-bot
Copy link

Can one of the admins verify this patch?

5 similar comments
@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

@swift-server-bot
Copy link

Can one of the admins verify this patch?

Copy link
Contributor

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

Couple of nits but looks good otherwise

@glbrntt
Copy link
Contributor

glbrntt commented Nov 30, 2022

@swift-server-bot add to allowlist

@glbrntt glbrntt added the 🆕 semver/minor Adds new public API. label Nov 30, 2022
@rnro rnro requested review from glbrntt and dnadoba and removed request for glbrntt November 30, 2022 11:55
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.

Can we move the changed generate_linux_tests.rb script and its associated changes to a new PR? They add loads of noise to this one, and they are unrelated.

@rnro rnro force-pushed the migrate_HTTP1_proxy_connect_handler branch 3 times, most recently from 5b34b99 to 6c4d28a Compare December 2, 2022 14:39
rnro added 5 commits December 5, 2022 10:27
Motivation:

Moving the HTTP1ProxyConnectHandler into swift-nio-extras will make the
code which is generally useful when dealing with HTTP1 proxies available
more easily to a wider audience.

Modifications:

The code and tests are copied over from https://github.com/swift-server/async-http-client/blob/0b5bec741bfcf941e208d937de2ec29affe750a7/Sources/AsyncHTTPClient/ConnectionPool/ChannelHandler/HTTP1ProxyConnectHandler.swift.

Result:

HTTP1ProxyConnectHandler will be surfaced via the NIOExtras library
- Add missing
`context.fireChannelActive()`,`context.fireChannelInactive()` to pass
along events down the pipeline.
- Make some members private
- include responseHEAD in invalid response errors
- remove precondition in favor of error in event of an unexpected proxy
  response
@rnro rnro force-pushed the migrate_HTTP1_proxy_connect_handler branch 3 times, most recently from cdf4d91 to 060c06d Compare December 5, 2022 10:33
@rnro rnro force-pushed the migrate_HTTP1_proxy_connect_handler branch from 060c06d to a2da342 Compare December 5, 2022 10:33
@rnro rnro requested review from glbrntt and removed request for glbrntt December 5, 2022 10:34
@rnro rnro requested a review from Lukasa December 5, 2022 10:34
- writes issued whilst the CONNECT is ongoing are now buffered rather
  than triggering a failure
- Error is restructured to do away with `Kind`
- failure logic is consolidated in `failWithError`
@rnro rnro force-pushed the migrate_HTTP1_proxy_connect_handler branch from da3ea0c to b34607e Compare December 15, 2022 14:44
@rnro rnro requested review from Lukasa and glbrntt and removed request for Lukasa December 15, 2022 14:44
@rnro rnro requested a review from glbrntt December 15, 2022 17:13
Copy link
Contributor

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

I think I'm more or less happy with this once https://github.com/apple/swift-nio-extras/pull/185/files#r1039437675 has been addressed.

HTTP1ProxyConnectHandler now errors rather than fails a precondition if
it becomes inactive unexpectedly when in initializing state
@rnro rnro requested a review from glbrntt December 20, 2022 15:41
Copy link
Member

@dnadoba dnadoba left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

Looks good, thanks @rnro!

@rnro rnro requested a review from Lukasa January 11, 2023 17:09
@rnro rnro force-pushed the migrate_HTTP1_proxy_connect_handler branch from 18678a6 to 619f10b Compare January 11, 2023 17:10
rnro added 2 commits January 11, 2023 17:16
unbuffering writes now flushes correctly if the buffer is flushed during
unbuffering
@rnro rnro force-pushed the migrate_HTTP1_proxy_connect_handler branch from 619f10b to 63473f9 Compare January 11, 2023 17:17
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.

Broadly looking great! One quick note.

to protect against concurrent modification
@rnro rnro requested a review from Lukasa January 12, 2023 08:50
@glbrntt glbrntt merged commit 5ff8cc5 into apple:main Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants