-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-33365: print the header values besides the keys #6611
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
bpo-33365: print the header values besides the keys #6611
Conversation
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 our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. When your account is ready, please add a comment in this pull request Thanks again to your contribution and we look forward to looking at it! |
I have signed the CLA already. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a news entry.
Lib/http/client.py
Outdated
@@ -321,7 +321,7 @@ def begin(self): | |||
|
|||
if self.debuglevel > 0: | |||
for hdr in self.headers: | |||
print("header:", hdr, end=" ") | |||
print("header:", hdr + ":", self.headers.get(hdr), end="\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
end="\n"
is needless.
3fe31ad
to
a128002
Compare
@serhiy-storchaka: I added the news entry and removed the |
@@ -0,0 +1 @@ | |||
print the header values besides the keys (debuglevel=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks unclear out of the context. Please explain what is changed.
Add a period, start the sentence with a title case, and please add "Path by yourname."
a128002
to
e638029
Compare
@serhiy-storchaka: I improved the news entry. Can you please have a look again? |
Would be nice to add also a test. Something like the existing test Seems that the same header is printed twice in |
6cf88d5
to
743769e
Compare
@serhiy-storchaka Sorry for the long delay, but I was busy the last weeks. I added a test and adopted your updated new entry. Thanks. Where does the raw header line get printed in |
Seems I just missed that other prints print other lines. |
Lib/test/test_httplib.py
Outdated
@@ -344,6 +344,17 @@ def test_invalid_headers(self): | |||
with self.assertRaisesRegex(ValueError, 'Invalid header'): | |||
conn.putheader(name, value) | |||
|
|||
def test_headers_debuglevel(self): | |||
body = b'HTTP/1.1 200 OK\r\nFirst: val\r\n: nval\r\nSecond: val\r\n\r\n' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What : nval
means?
I think it would be better to write this literal as multiple lines, splitting at newlines.
body = (b'HTTP/1.1 200 OK\r\n'
b'First: val\r\n'
...
with debuglevel=1 only the header keys got printed. With this change the header values get printed as well and the single header entries get '\n' as a separator.
743769e
to
1456e95
Compare
@serhiy-storchaka: fixed the copy and paste error in body (removed the |
Thanks @lethliel for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7. |
Thanks @lethliel for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6. |
with debuglevel=1 only the header keys got printed. With this change the header values get printed as well and the single header entries get '\n' as a separator. (cherry picked from commit 936f03e) Co-authored-by: Marco Strigl <[email protected]>
GH-7792 is a backport of this pull request to the 3.7 branch. |
with debuglevel=1 only the header keys got printed. With this change the header values get printed as well and the single header entries get '\n' as a separator. (cherry picked from commit 936f03e) Co-authored-by: Marco Strigl <[email protected]>
GH-7793 is a backport of this pull request to the 3.6 branch. |
with debuglevel=1 only the header keys got printed. With this change the header values get printed as well and the single header entries get '\n' as a separator. (cherry picked from commit 936f03e) Co-authored-by: Marco Strigl <[email protected]>
with debuglevel=1 only the header keys got printed. With this change the header values get printed as well and the single header entries get '\n' as a separator. (cherry picked from commit 936f03e) Co-authored-by: Marco Strigl <[email protected]>
With
debuglevel=1
only the header keys got printed. With this change the header values get printed as well and the single header entries get '\n' as a separator.https://bugs.python.org/issue33365