Skip to content

urllib does not splitport while putrequest realhost to HTTP headers #71486

Closed

Description

@grzhang
mannequin
BPO 27299
Nosy @bitdancer, @zhangyangyu
Files
  • urllib_part.py
  • 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 2016-06-18.19:30:11.260>
    created_at = <Date 2016-06-12.04:10:49.837>
    labels = ['invalid', 'type-bug', 'library']
    title = 'urllib does not splitport while putrequest realhost to HTTP headers'
    updated_at = <Date 2016-06-18.19:30:11.258>
    user = 'https://bugs.python.org/grzhang'

    bugs.python.org fields:

    activity = <Date 2016-06-18.19:30:11.258>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-06-18.19:30:11.260>
    closer = 'r.david.murray'
    components = ['Library (Lib)']
    creation = <Date 2016-06-12.04:10:49.837>
    creator = 'gr zhang'
    dependencies = []
    files = ['43356']
    hgrepos = []
    issue_num = 27299
    keywords = []
    message_count = 5.0
    messages = ['268317', '268318', '268326', '268357', '268827']
    nosy_count = 3.0
    nosy_names = ['r.david.murray', 'xiang.zhang', 'gr zhang']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue27299'
    versions = ['Python 2.7']

    Activity

    1. grzhang commented on Jun 12, 2016

      grzhangmannequin
      MannequinAuthor
      h.putheader('Host', "www.github.com:443")             
      # this will make errcode 405, if urllib lib splitport first, and this will set Host ---> www.github.com and get 200 code.
      h.endheaders(None)
      errcode, errmsg, headers = h.getreply()
      print errcode
    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on Jun 12, 2016
    3. zhangyangyu commented on Jun 12, 2016

      @zhangyangyu
      Member

      The standard[1] says the Host header is OK to include port. Why not use 'https://www.github.com'?

      [1] https://tools.ietf.org/html/rfc7230#section-5.4

    4. grzhang commented on Jun 12, 2016

      grzhangmannequin
      MannequinAuthor

      Yes, I mean when set h.putheader('Host', "www.github.com:443") and the status code from httplib will be 405 while when set h.putheader('Host', "www.github.com") the code will be 200, this is confused to me.

    5. zhangyangyu commented on Jun 12, 2016

      @zhangyangyu
      Member

      It's server side behaviour. Asking here may not get results. I think it's normal for the server to return error if it thinks the header is invalid.

    6. bitdancer commented on Jun 18, 2016

      @bitdancer
      Member

      httplib (which is what you are actually calling in your example) does not interpret headers set with putheader. It is the application's responsibility to get the header contents correct. As Xiang said, this looks like a server side issue.

    7. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions