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

urllib mock does not return HTTPMessage for response.headers #151

Closed
sarayourfriend opened this issue Oct 24, 2024 · 0 comments · Fixed by #154
Closed

urllib mock does not return HTTPMessage for response.headers #151

sarayourfriend opened this issue Oct 24, 2024 · 0 comments · Fixed by #154
Labels

Comments

@sarayourfriend
Copy link
Collaborator

Pook's urllib mock returns a dict for headers, whereas the standard library implementation always returns an HTTPMessage. The docs here say they return an email.message.Message, of which HTTPMessage is a subclass.

This is true for Pythons 3.9 through to 3.13 (the currently supported range):

Python 3.9.19 (main, Apr 15 2024, 18:17:55) 
[Clang 17.0.6 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib.request import urlopen
>>> response = urlopen("https://google.com")
>>> response.headers
<http.client.HTTPMessage object at 0x7f7a106ab070>
Python 3.13.0 (main, Oct 15 2024, 18:13:10) [GCC 14.2.1 20240912 (Red Hat 14.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib.request import urlopen
>>> response = urlopen("https://google.com")
>>> response.headers
<http.client.HTTPMessage object at 0x7fd4b9dbf100>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant