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

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

Closed
alienlifeform mannequin opened this issue Nov 12, 2004 · 2 comments
Closed

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

alienlifeform mannequin opened this issue Nov 12, 2004 · 2 comments
Labels
extension-modules C modules in the Modules dir

Comments

@alienlifeform
Copy link
Mannequin

alienlifeform mannequin commented Nov 12, 2004

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 = []

    @alienlifeform
    Copy link
    Mannequin Author

    alienlifeform mannequin commented Nov 12, 2004

    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

    @alienlifeform alienlifeform mannequin closed this as completed Nov 12, 2004
    @alienlifeform alienlifeform mannequin added the extension-modules C modules in the Modules dir label Nov 12, 2004
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Nov 12, 2006

    Logged In: YES
    user_id=21627

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

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    extension-modules C modules in the Modules dir
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants