Skip to content

bpo-36522: Print all values for headers with multiple values #12681

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

Merged

Conversation

houglum
Copy link
Contributor

@houglum houglum commented Apr 4, 2019

This is a follow-up to https://bugs.python.org/issue33365. The fix for that issue (see #6611) added a statement to also print header values, but it does not account for the case where multiple values exist for the same header name (note that multiple header values for the same header name can be supplied in one comma-separated entry, or in multiple entries; see this StackOverflow post). E.g. if my response contained these headers:

x-goog-hash: crc32c=KAwGng==
x-goog-hash: md5=eB5eJF1ptWaXm4bijSPyxw==

then the debug output would print whichever of those values is returned from self.headers.get("x-goog-hash") for both prints:

header: x-goog-hash: crc32c=KAwGng==
header: x-goog-hash: crc32c=KAwGng==

This PR changes the header iteration to use self.headers.items() instead, which will return the key and value pair to be printed, resulting in the correct debug output:

header: x-goog-hash: crc32c=KAwGng==
header: x-goog-hash: md5=eB5eJF1ptWaXm4bijSPyxw==

https://bugs.python.org/issue36522

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

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

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

@houglum
Copy link
Contributor Author

houglum commented Apr 4, 2019

Just signed the CLA and added a NEWS entry.

@miss-islington
Copy link
Contributor

Thanks @houglum for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@serhiy-storchaka
Copy link
Member

Thank you for your contribution @houglum!

@bedevere-bot
Copy link

GH-12682 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 4, 2019
serhiy-storchaka pushed a commit that referenced this pull request Apr 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants