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 'headers' is not a well defined data type #65110

Closed
bitdancer opened this issue Mar 13, 2014 · 5 comments
Closed

urllib 'headers' is not a well defined data type #65110

bitdancer opened this issue Mar 13, 2014 · 5 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@bitdancer
Copy link
Member

BPO 20911
Nosy @bitdancer, @demianbrecht

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2019-01-24.23:51:33.810>
created_at = <Date 2014-03-13.15:27:34.390>
labels = ['type-bug']
title = "urllib 'headers' is not a well defined data type"
updated_at = <Date 2019-01-24.23:51:33.809>
user = 'https://github.com/bitdancer'

bugs.python.org fields:

activity = <Date 2019-01-24.23:51:33.809>
actor = 'demian.brecht'
assignee = 'none'
closed = True
closed_date = <Date 2019-01-24.23:51:33.810>
closer = 'demian.brecht'
components = []
creation = <Date 2014-03-13.15:27:34.390>
creator = 'r.david.murray'
dependencies = []
files = []
hgrepos = []
issue_num = 20911
keywords = []
message_count = 5.0
messages = ['213406', '237381', '334246', '334270', '334327']
nosy_count = 2.0
nosy_names = ['r.david.murray', 'demian.brecht']
pr_nums = []
priority = 'normal'
resolution = 'out of date'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue20911'
versions = []

@bitdancer
Copy link
Member Author

Some places in the code it is an email.message.Message object. Some places it is a simple dictionary. In one place (FTP), it is a string with embedded newlines.

I'm not sure what should be done about this situation, but it looks like a bug magnet, and it makes it pretty much impossible to document the data type.

@bitdancer bitdancer added the type-bug An unexpected behavior, bug, or error label Mar 13, 2014
@BreamoreBoy
Copy link
Mannequin

BreamoreBoy mannequin commented Mar 6, 2015

@demian I believe this maybe of interest to you.

@demianbrecht
Copy link
Mannequin

demianbrecht mannequin commented Jan 23, 2019

@r. David Murray

Is this issue still valid? Running 3.6 it seems that http and ftp are consistent at any rate (http returns http.client.HTTPMessage and ftp returns email.message.Message). If it's still an issue, could you please elaborate?

@bitdancer
Copy link
Member Author

There has been considerable rewriting of the header handling code since I filed this. I would not be surprised if the issue is no longer valid. If you want to double check, look for the places that the headers attribute is created in the various handlers. Otherwise you can just close this as out of date.

@demianbrecht
Copy link
Mannequin

demianbrecht mannequin commented Jan 24, 2019

>>> urlopen('https://example.com').info()
<http.client.HTTPMessage object at 0x111528da0>
>>> urlopen('http://example.com').info()
<http.client.HTTPMessage object at 0x111528be0>
>>> urlopen('ftp://speedtest.tele2.net').info()
<email.message.Message object at 0x111531080>
>>> urlopen('file:///path/to/setup.py').info()
<email.message.Message object at 0x111528f60>

I've taken a look at the rest of the handlers in urllib.request and they all build headers consistently with email.message_from_string().

Closing as out of date.

@demianbrecht demianbrecht mannequin closed this as completed Jan 24, 2019
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
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

No branches or pull requests

1 participant