Skip to content

urllib2: request with digest auth through proxy fail #48390

Closed

Description

@jankollhof
BPO 4140
Nosy @gpshead, @orsenthil
Files
  • urllib2.py: patched urllib2
  • 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 2013-04-18.05:08:29.195>
    created_at = <Date 2008-10-17.15:45:31.178>
    labels = ['invalid', 'type-bug', 'library']
    title = 'urllib2: request with digest auth through proxy fail'
    updated_at = <Date 2013-04-18.05:08:29.194>
    user = 'https://bugs.python.org/jankollhof'

    bugs.python.org fields:

    activity = <Date 2013-04-18.05:08:29.194>
    actor = 'orsenthil'
    assignee = 'orsenthil'
    closed = True
    closed_date = <Date 2013-04-18.05:08:29.195>
    closer = 'orsenthil'
    components = ['Library (Lib)']
    creation = <Date 2008-10-17.15:45:31.178>
    creator = 'jan.kollhof'
    dependencies = []
    files = ['11819']
    hgrepos = []
    issue_num = 4140
    keywords = []
    message_count = 5.0
    messages = ['74918', '109733', '109964', '186851', '187221']
    nosy_count = 6.0
    nosy_names = ['gregory.p.smith', 'jjlee', 'orsenthil', 'jan.kollhof', 'jesstess', 'BreamoreBoy']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue4140'
    versions = ['Python 3.1', 'Python 2.7']

    Activity

    1. jankollhof commented on Oct 17, 2008

      jankollhofmannequin
      MannequinAuthor

      When using a proxy to request URLs that require Digest Auth,
      a header similar to the following is sent to the server:

      Authorization: Digest ... uri="http://example.org/foobar/spam" ...

      The server then responded with:

      HTTP/1.1 400 Bad Request
      Server: Microsoft-IIS/6.0

      When not using a proxy, the header sent will look like:

      Authorization: Digest ... uri="/foobar/spam" ...

      and the server responded as expected with a 200 OK.

      I don't know what is at fault here, urllib2 or IIS,
      but patching the urllib2 to not use the full URL, when creating
      the Digest Auth. header, works.

      When a proxy is being used by urllib2, the Request's get_selector() will
      always return the full URL instead of just the selector.
      The code that creates the Digest auth. header also uses the
      get_selector() to set the "uri="-part in the auth header.
      Making sure that the "uri="-part is not a full URL all seems to work.
      See the patched urllib2.py attached.

      I have only tested the fix against the server I had problems with,
      and it seems to be working.

    2. added
      stdlib
      type-bug
      on Oct 17, 2008
    3. self-assigned this
      on Dec 4, 2008
    4. BreamoreBoy commented on Jul 9, 2010

      BreamoreBoymannequin
      Mannequin

      As it's not actually known whether urllib2 or IIS is at fault, I suggest this is closed, it can always be reopened.

    5. orsenthil commented on Jul 11, 2010

      @orsenthil
      Member

      This might be related to bpo-2202 as well.

    6. jesstess commented on Apr 13, 2013

      @jesstess
      Member

      jan.kollhof, thanks for the report and your work on this ticket!

      The format of the client response to a server's digest challenge is detailed in RFC 2617, section 3.2.2: The Authorization Request Header.

      The urllib2.py attachment is unfortunately the whole file and not a diff, but I think from the transcript in msg74918 that Jan is discussing the format of the digest-uri header. That field is in turn defined in RFC 2616, section 5.1.2: Request-URI.

      Request-URI    = "*" | absoluteURI | abs_path | authority
      
      The absoluteURI form is REQUIRED when the request is being made to a
      

      proxy.

      So I believe urllib2 has the correct, RFC-conforming behavior here by sending the full URI through a proxy, and the issue is with IIS.

      Thus, I recommend that we close this ticket as invalid.

    7. orsenthil commented on Apr 18, 2013

      @orsenthil
      Member

      Yes, RFC specifically states that "The absoluteURI form is REQUIRED when the request is being made to a proxy." Thanks Jessica for making a note of that. Closing this issue as Invalid.

    8. 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

    Labels

    stdlibtype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions