Skip to content

add options to override tcp hostname and tls hostname - #2080

Closed
toppk wants to merge 4 commits into
encode:masterfrom
toppk:buddy_extensions
Closed

toppk wants to merge 4 commits into
encode:masterfrom
toppk:buddy_extensions

Conversation

@toppk

@toppk toppk commented Feb 10, 2022

Copy link
Copy Markdown
Contributor

this requires new extensions inside httpcore (encode/httpcore#507)

Here is a snipped I used to test this.
python -c 'import httpx; import sys;httpx.main(sys.argv[1:])' https://neverin.org/headers --x-connect-to 54.221.78.73 --x-sni-hostname httpbin.org

Comment thread httpx/_main.py Outdated
Comment on lines +495 to +497
extensions: typing.Dict[str, typing.Any] = {
"trace": functools.partial(trace, verbose=verbose)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need to type annotate this?
If we do (because of our tooling) then does just extensions: dict also pass?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, it was autolabelling with Partial[None] from "trace". just "dict" works. (pushed)

@toppk

toppk commented Feb 10, 2022

Copy link
Copy Markdown
Contributor Author

i am working on a test case for connect_to, but a test case for sni_hostname will be more involved, since we don't create a tls server inside the test suit currently (i think).

@lovelydinosaur

Copy link
Copy Markdown
Member

i am working on a test case for connect_to, but a test case for sni_hostname will be more involved, since we don't create a tls server inside the test suit currently (i think).

I wouldn't worry about it. It'd be enough either to pragma: nocover it, or else to include sni_hostname on a test case that isn't actually against an https URL.

(The line itself is trivially simple, so... 🤷‍♂️)

@lovelydinosaur

Copy link
Copy Markdown
Member

My workflow for testing stuff direct from branches these days is looking like this...

$ python3.9 -m venv venv

# Install your `buddy_extensions` branch of httpcore
$ venv/bin/pip install git+https://github.com/toppk/httpcore.git@buddy_extensions

# Install your `buddy_extensions` branch of httpx, including the optional cli dependancies
$ venv/bin/pip install "httpx[cli] @ git+https://github.com/toppk/httpx.git@buddy_extensions"

# Everything's installed and working as expected...
$ venv/bin/httpx https://neverin.org/headers --x-connect-to 35.171.190.227 --x-sni-hostname www.httpbin.org
HTTP/1.1 200 OK
Date: Thu, 10 Feb 2022 17:19:05 GMT
Content-Type: application/json
Content-Length: 222
Connection: keep-alive
Server: gunicorn/19.9.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true

{
    "headers": {
        "Accept": "*/*",
        "Accept-Encoding": "gzip, deflate",
        "Host": "neverin.org",
        "User-Agent": "python-httpx/0.22.0",
        "X-Amzn-Trace-Id": "Root=1-62054909-2b49d49373a4dc8b585dea22"
    }
}

@toppk

toppk commented Feb 10, 2022

Copy link
Copy Markdown
Contributor Author

My workflow for testing stuff direct from branches these days is looking like this...

okay. I haven't done a pip with git yet, but it seems very handy. my workflow is not as perfect. I generally avoid venvs because i like to live in a messy world. i think we're overdue to bump the revs on the test suite.

in anycase I've added the test case for connect_to, and included sni_hostname in there for simplicity.

@toppk

toppk commented Feb 10, 2022

Copy link
Copy Markdown
Contributor Author

this works on my 3.9, but not on my 3.6. investigating now...

@toppk

toppk commented Feb 10, 2022

Copy link
Copy Markdown
Contributor Author

silly me, this will not work until a httpcore is released.. I consider this done pending that event.

@stale

stale Bot commented Mar 15, 2022

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants