-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add target
request extension
#888
Conversation
Okay... interesting. I was expecting this to be applied in We actually support this in Perhaps that distinction is subtle enough that it makes sense for us to apply this extension at the Note to self our Request/Response/URL docs are missing here... https://github.com/encode/httpcore/blob/d4678e61b0af24747676c18fb0cb0b2027867bb0/docs/requests-responses-urls.md |
I thought it is more natural to have this kind of extension logic in the httpcore package + all the transports will support it. |
How does this (does this?) effect (affect?) the proxies? |
So here's where I was expecting we'd implement this... Thoughts? |
I don't see any differences, If you like to see this at the httpx layer, I can close this one and open a new PR. But, is there anything wrong with this one? Passing the target extension directly to the H11 target makes more sense to me. |
You're probably right that it's sensible to implement this directly in I think the neatest way is implementing this elsewhere... Line 354 in 908013c
if 'target' in extensions:
self.url = URL(
scheme=self.url.scheme,
host=self.url.host,
port=self.url.port,
target=extensions['target'],
) That'll update the target once, and be passed through everywhere. Reasonable? |
Much neater, thanks. |
Looks good, thanks. 😊 I'd suggest also updating the Lines 212 to 219 in 908013c
Since we can now express this with... url = "http://127.0.0.1:8080"
extensions = {"target: "http://www.example.com"}
with httpcore.stream("CONNECT", url, extensions=extensions) as response: Then, yep let's get this in. |
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.
Made a couple of additional docs changes on top of this.
Fantastic addition, thanks @karpetrosyan. 🎉
Refs: encode/httpx#2949 (reply in thread)
This PR adds a target extension, which can be used to force HTTP target to a specific bytes-encoded string.
Check out https://developer.mozilla.org/en-US/docs/Web/HTTP/Messages#request_line to read more about HTTP message structure and what HTTP target is.