Skip to content
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 SKIP_HEADER for skipping automatically added headers #2018

Merged
merged 5 commits into from Oct 27, 2020

Conversation

sethmlarson
Copy link
Member

@sethmlarson sethmlarson commented Oct 5, 2020

Closes #2014, Closes #2021

Changed the sentinel from SUPPRESS_USER_AGENT to SKIP_HEADER for skipping 3 of the automatically added headers Accept-Encoding, Host, and User-Agent.

cc @nateprewitt could you test this to ensure it works as you're expecting?

src/urllib3/connection.py Outdated Show resolved Hide resolved
Co-authored-by: hodbn <hodbn@users.noreply.github.com>
@sethmlarson
Copy link
Member Author

Thanks @hodbn for the test case, I added you as a coauthor to the patch you sent me :)

@codecov
Copy link

codecov bot commented Oct 16, 2020

Codecov Report

Merging #2018 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #2018   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           25        25           
  Lines         2290      2298    +8     
=========================================
+ Hits          2290      2298    +8     
Impacted Files Coverage Δ
src/urllib3/util/__init__.py 100.00% <ø> (ø)
src/urllib3/_collections.py 100.00% <100.00%> (ø)
src/urllib3/connection.py 100.00% <100.00%> (ø)
src/urllib3/util/request.py 100.00% <100.00%> (ø)
src/urllib3/util/ssl_.py 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1f05ae...57f76e1. Read the comment docs.

src/urllib3/connection.py Outdated Show resolved Hide resolved
src/urllib3/connection.py Outdated Show resolved Hide resolved
src/urllib3/connection.py Show resolved Hide resolved
@sethmlarson sethmlarson changed the title Fix SKIP_USER_AGENT for non-ASCII headers Add SKIP_HEADER for skipping automatically added headers Oct 18, 2020
@sethmlarson
Copy link
Member Author

@hodbn Thanks for the review, good catch on the copy issue. HTTPConnectionPool was saving us with a .copy() call due to proxy headers but we can't rely on that at the HTTPConnection level. Added stricter test cases for this.

This was referenced Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't modify type of headers object within HTTPConnection.request() Discussion around 1.26.0 header encoding
3 participants