Uh oh!
There was an error while loading. Please reload this page.
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 |
karpetrosyan
commented
Feb 14, 2024
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? |
lovelydinosaur
commented
Feb 15, 2024
So here's where I was expecting we'd implement this... Thoughts? |
karpetrosyan
commented
Feb 15, 2024
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. |
lovelydinosaur
commented
Feb 15, 2024
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'inextensions:
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? |
karpetrosyan
commented
Feb 15, 2024
Much neater, thanks. |
Uh oh!
There was an error while loading. Please reload this page.
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"}
withhttpcore.stream("CONNECT", url, extensions=extensions) asresponse: Then, yep let's get this in. |
lovelydinosaur
left a comment
There was a problem hiding this comment.
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.