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

Urllib2 user-agent header added by an opener is "frozen" #44227

Closed
derdoener mannequin opened this issue Nov 13, 2006 · 5 comments
Closed

Urllib2 user-agent header added by an opener is "frozen" #44227

derdoener mannequin opened this issue Nov 13, 2006 · 5 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@derdoener
Copy link
Mannequin

derdoener mannequin commented Nov 13, 2006

BPO 1595365
Nosy @orsenthil, @devdanzin
Files
  • header-bug.txt: Sample output showing the problem
  • 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 = 'https://github.com/orsenthil'
    closed_at = <Date 2010-09-27.01:41:28.417>
    created_at = <Date 2006-11-13.02:27:55.000>
    labels = ['type-bug', 'library']
    title = 'Urllib2 user-agent header added by an opener is "frozen"'
    updated_at = <Date 2010-09-27.01:41:28.416>
    user = 'https://bugs.python.org/derdoener'

    bugs.python.org fields:

    activity = <Date 2010-09-27.01:41:28.416>
    actor = 'orsenthil'
    assignee = 'orsenthil'
    closed = True
    closed_date = <Date 2010-09-27.01:41:28.417>
    closer = 'orsenthil'
    components = ['Library (Lib)']
    creation = <Date 2006-11-13.02:27:55.000>
    creator = 'der_doener'
    dependencies = []
    files = ['2212']
    hgrepos = []
    issue_num = 1595365
    keywords = ['patch']
    message_count = 5.0
    messages = ['30531', '86315', '116182', '117126', '117435']
    nosy_count = 4.0
    nosy_names = ['orsenthil', 'der_doener', 'ajaksu2', 'BreamoreBoy']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue1595365'
    versions = ['Python 3.1', 'Python 2.7', 'Python 3.2']

    @derdoener
    Copy link
    Mannequin Author

    derdoener mannequin commented Nov 13, 2006

    If a Request object gets an User-agent header added by
    an opener, that header seems to be "frozen". Although
    header_items() shows the changed header, the request
    still uses the old one. This does not happen if the
    header is set before the request is passed to the
    opener, i.e. when the header is not set automatically,
    subsequent changes are respected.

    I'm using Python 2.4.4 from Debian's sid.

    @devdanzin devdanzin mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Feb 12, 2009
    @devdanzin
    Copy link
    Mannequin

    devdanzin mannequin commented Apr 22, 2009

    Confirmed in trunk.

    Easier to copy and paste:

    import urllib2
    h = urllib2.HTTPHandler(debuglevel = 1)
    opener = urllib2.build_opener(h)
    
    request = urllib2.Request('http://www.google.de/')
    request.header_items()
    
    opener.open(request)
    request.header_items()
    
    request.add_header('User-agent', 'Buggy')
    request.header_items()
    
    opener.open(request)

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Sep 12, 2010

    What is the status of this issue?

    @BreamoreBoy BreamoreBoy mannequin changed the title User-agent header added by an opener is "frozen" Urllib2 user-agent header added by an opener is "frozen" Sep 12, 2010
    @BreamoreBoy BreamoreBoy mannequin changed the title User-agent header added by an opener is "frozen" Urllib2 user-agent header added by an opener is "frozen" Sep 12, 2010
    @orsenthil
    Copy link
    Member

    This is still a valid bug.

    @orsenthil
    Copy link
    Member

    Fixed in r85025 (py3k), r85026 (release31-maint) and r85027 (release27-maint).

    @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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant