Skip to content

httplib: allowing stream-type body part in requests #41165

Closed

Description

@alienlifeform
BPO 1065257
Nosy @loewis
Files
  • httplib2.patch: httplib: allowing stream-type body part in requests
  • 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 2006-11-12.10:33:12.000>
    created_at = <Date 2004-11-12.15:48:57.000>
    labels = ['extension-modules']
    title = 'httplib: allowing stream-type body part in requests'
    updated_at = <Date 2006-11-12.10:33:12.000>
    user = 'https://bugs.python.org/alienlifeform'

    bugs.python.org fields:

    activity = <Date 2006-11-12.10:33:12.000>
    actor = 'loewis'
    assignee = 'none'
    closed = True
    closed_date = None
    closer = None
    components = ['Extension Modules']
    creation = <Date 2004-11-12.15:48:57.000>
    creator = 'alien_life_form'
    dependencies = []
    files = ['6362']
    hgrepos = []
    issue_num = 1065257
    keywords = ['patch']
    message_count = 2.0
    messages = ['47287', '47288']
    nosy_count = 2.0
    nosy_names = ['loewis', 'alien_life_form']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1065257'
    versions = []

    Activity

    1. alienlifeform commented on Nov 12, 2004

      alienlifeformmannequin
      MannequinAuthor

      Greetings.

      The attached patch makes it possible to use a file-like
      object in httplib requests (useful to PUT large files
      without exhausting the machine memory - think a DAV
      server).

      The supplied object must be able to read().

      If Content-Length support is desired, the body object
      must either have a __length__ method (so len(body)
      works) OR have a stat-able "name" property (file
      objects are in the second category).

      Having applied this patch the following works:

         import httplib
          import base64
          hh={}
          auth = base64.encodestring("%s:%s" %
      ("guest","guest")).rstrip()
          hh['Authorization']='Basic %s' % auth
          conn=HTTPConnection('localhost',8080)
          conn.debuglevel=99
          thestream=open(r'\tmp\huge.pdf','rb')
          conn.request('PUT',
                       '/dav/streamed',
                       thestream,hh)
          thestream.close()
          rsp=conn.getresponse()
          print
      rsp.status,"-",rsp.reason,repr(rsp.msg.dict),rsp.read()
          conn.close()

      Opening in 'rb' mode - on windoze - is important for
      this to work, or the content length header will be
      wrong, which is probably BAD.

      Alessandro Forghieri

    2. added
      extension-modules
      on Nov 12, 2004
    3. loewis commented on Nov 12, 2006

      loewismannequin
      Mannequin

      Logged In: YES
      user_id=21627

      Thanks for the patch. Committed (with modifications) as r52736.

    4. transferred this issue fromon Apr 9, 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

      extension-modules

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions