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
Follow cURL's rules for parsing and matching NO_PROXY #1332
Conversation
Thanks for this! I think trying to match curl's rules is a great goal. Just to help me reason on the change, will this "break" any behavior that people might have come to rely on? I realize in a crazy way, people can rely on any ol' bug, but I mean if things were sufficiently different. |
The addition of wildcard ( This does change behavior in a breaking way for a couple cases:
I would argue that the first of these changes is absolutely correct (i.e. if this breaks someone, they need to fix their I can undo that second bit if you think it is safer. So: in this instance, should reqwest prefer better compatibility with the existing behavior, or copy cURL's behavior? (I'm torn) |
I should add that reqwest's |
This commit makes NO_PROXY entries without leading dots match subdomains (which they had not done previously). Additionally, the magic entry "*" matches all domains (effectively disabling use of the proxy).
@seanmonstar Rebased against master, reverted the (incompatible) bit where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted the (incompatible) bit where NO_PROXY entries beginning with . no longer matched themselves
I kinda think we could make that change even though it's breaking, since it doesn't seem like someone would normally be using .foo.bar
unless trying to get the exact behavior of curl. But we can also make that a follow-up... Either way, thanks for this! It's excellent!
There are a few ways in which reqwest's handling of
NO_PROXY
differs from cURL (and other implementations). The biggest issue is that whitespace between entries should be ignored/trimmed, but is not (i.e. "NO_PROXY='a, b'
" would never match "b
"). In addition, according to cURL's rules, aNO_PROXY
entry without a leading dot should match the domain itself as well as any subdomains (reqwest only handles exact matches if there is no leading dot) and entries with a leading dot should only match subdomains (but request allows exact matches). Finally, cURL allows a special entry "*
" to match all entries (effectively disabling use of the proxy).All changes in behavior have corresponding changes to the tests.
I tried to keep the logic clear/clean/idiomatic but I'm definitely open to suggestions for improvement.