◐ Shell
reader mode source ↗
Skip to content

gh-69152: Add _proxy_response_headers attribute to HTTPConnection#26152

Merged
orsenthil merged 7 commits into
python:mainfrom
nametkin:add_proxy_response_headers
May 5, 2023
Merged

gh-69152: Add _proxy_response_headers attribute to HTTPConnection#26152
orsenthil merged 7 commits into
python:mainfrom
nametkin:add_proxy_response_headers

Conversation

@nametkin

@nametkin nametkin commented May 15, 2021

Copy link
Copy Markdown
Contributor

It would be nice to be able to access the proxy response headers after tunneling through the proxy. Now these headers can only be obtained in debug mode.
This is necessary both for the case of a successful connection, and for the case of problems with establishing a connection (for example, in order to see the type of authentication required). Later, having access to the header Proxy-Authenticate, it will be possible to simplify the authentication on the proxy server in the dependent libraries urllib3, requests. There are problems with this now (Digest Proxy Auth, NTLM Proxy Auth, Kerberos Proxy Auth)

My proposed version is based on the idea proposed by Thomas Belhalfaoui in issue 24964. And also on the approach used in the library http.rb (here)

https://bugs.python.org/issue24964

@the-knights-who-say-ni

Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

CLA Missing

Our records indicate the following people have not signed the CLA:

@OneMoreZanuda

For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Jun 16, 2021

@MaxwellDupre MaxwellDupre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hide comment

Looks ok

@nametkin

Copy link
Copy Markdown
Contributor Author

@vadmium, could you take a look at this?

@nametkin

Copy link
Copy Markdown
Contributor Author

@MaxwellDupre, thanks for the review!

@github-actions github-actions Bot removed the stale label Aug 8, 2022
@nametkin nametkin force-pushed the add_proxy_response_headers branch from efa9212 to 3258e0a Compare October 11, 2022 09:05
@ghost

ghost commented Oct 11, 2022

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.
CLA signed

@nametkin nametkin force-pushed the add_proxy_response_headers branch 2 times, most recently from 15e31c8 to ef3244d Compare April 23, 2023 11:02
@nametkin

Copy link
Copy Markdown
Contributor Author

Hi @orsenthil ! Could you take a look at this request? I see that you have worked a lot with module http/client.py. And I also found out that you were a reviewer for another PR with changes to the http/client.py. Or maybe you can recommend someone who could look at this code?

@orsenthil

Copy link
Copy Markdown
Member

@nametkin, sure. I will.

@orsenthil orsenthil self-assigned this Apr 23, 2023
@arhadthedev arhadthedev changed the title bpo-24964: Add _proxy_response_headers attribute to HTTPConnection Apr 24, 2023
@nametkin nametkin force-pushed the add_proxy_response_headers branch 6 times, most recently from 8d1ea4d to 3e0cdf9 Compare April 28, 2023 21:56
15 hidden items Load more…
@nametkin nametkin force-pushed the add_proxy_response_headers branch from 3e0cdf9 to ec7f577 Compare April 29, 2023 17:20

@orsenthil orsenthil left a comment

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.

Hide comment

We might atleast want to make parse_headers equivalent to the lines of code being removed.

@bedevere-bot

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@nametkin

nametkin commented May 5, 2023

Copy link
Copy Markdown
Contributor Author

@orsenthil, please look at the two comments above (in conversation). Can we leave the PR in its current state? Or just in case, we should add if not line condition?

@arhadthedev arhadthedev added the stdlib Standard Library Python modules in the Lib/ directory label May 5, 2023
@arhadthedev

Copy link
Copy Markdown
Member

@nametkin Could you sign the new CLA by clicking not signed button in the cpython-cla-bot's message, please? The message is above, posted Oct 11, 2022.

@nametkin

nametkin commented May 5, 2023

Copy link
Copy Markdown
Contributor Author

@nametkin Could you sign the new CLA by clicking not signed button in the cpython-cla-bot's message, please? The message is above, posted Oct 11, 2022.

Done.

@arhadthedev arhadthedev requested a review from orsenthil May 5, 2023 07:31

@orsenthil orsenthil left a comment

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.

Hide comment

The change looks good to me. Thanks, @nametkin

@orsenthil

Copy link
Copy Markdown
Member

@gpshead - fyi.

@orsenthil orsenthil enabled auto-merge (squash) May 5, 2023 18:29
@orsenthil orsenthil merged commit 1afe0e0 into python:main May 5, 2023
@nametkin nametkin deleted the add_proxy_response_headers branch May 5, 2023 19:02
carljm added a commit to carljm/cpython that referenced this pull request May 5, 2023
* main:
  pythongh-99113: Add PyInterpreterConfig.own_gil (pythongh-104204)
  pythongh-104146: Remove unused var 'parser_body_declarations' from clinic.py (python#104214)
  pythongh-99113: Add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED (pythongh-104205)
  pythongh-104108: Add the Py_mod_multiple_interpreters Module Def Slot (pythongh-104148)
  pythongh-99113: Share the GIL via PyInterpreterState.ceval.gil (pythongh-104203)
  pythonGH-100479: Add `pathlib.PurePath.with_segments()` (pythonGH-103975)
  pythongh-69152: Add _proxy_response_headers attribute to HTTPConnection (python#26152)
  pythongh-103533: Use PEP 669 APIs for cprofile (pythonGH-103534)
  pythonGH-96803: Add three C-API functions to make _PyInterpreterFrame less opaque for users of PEP 523. (pythonGH-96849)
jbower-fb pushed a commit to jbower-fb/cpython that referenced this pull request May 8, 2023
…on (python#26152)

Add _proxy_response_headers attribute to HTTPConnection (python#26152)

---------

Co-authored-by: Senthil Kumaran <senthil@python.org>
gpshead added a commit that referenced this pull request May 16, 2023
…ss (#104248)

Add http.client.HTTPConnection method get_proxy_response_headers() - this is a followup to #26152 which added it as a non-public attribute. This way we don't pre-compute a headers dictionary that most users will never access. The new method is properly public and documented and triggers full proxy header parsing into a dict only when actually called.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stdlib Standard Library Python modules in the Lib/ directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants