Code Monkey home page Code Monkey logo

Comments (13)

gerazenobi avatar gerazenobi commented on August 24, 2024 2

Hi, I was wondering if this was still an issue or not since the pull request #1030 was actually closed?

Cheers.

from urllib3.

jtolio avatar jtolio commented on August 24, 2024

i think you can send files blocks at a time. if the body= of your request is a file like object, it will iteratively call .read() with a reasonable block size.

from urllib3.

allover avatar allover commented on August 24, 2024

[Deleted by shazow]

from urllib3.

jtolio avatar jtolio commented on August 24, 2024

[... Deleted by shazow]

Iterative block sending works not because urllib3 implements it, but because urllib3 hands off the body sending part to the builtin httplib module directly, which does support this.

I'll prove it. In ConnectionPool's urlrequest, body is passed along to ConnectionPool _make_request. _make_request accepts the body keyword arg into the httplib_request_kw keyword arg catcher. You'll notice that's passed on to conn.request. 'conn' here is of type HTTPConnection, straight from httplib.

In httplib, HTTPConnection request takes body and sends it to _send_request. _send_request takes body and passes it along to send. send accepts body as 'str', has a blocksize of 8192 hardcoded in, and if 'str' has a 'read' method defined on it, will loop on reading that blocksize.

from urllib3.

jtolio avatar jtolio commented on August 24, 2024

[Deleted by shazow]

from urllib3.

kennethreitz avatar kennethreitz commented on August 24, 2024

Please be respectful.

from urllib3.

shazow avatar shazow commented on August 24, 2024

Yes, please be nice as @kennethreitz said.

I don't recall the exact details of this off hand but what @jtolds sounds plausible. I will confirm this weekend and update this bug accordingly.

from urllib3.

allover avatar allover commented on August 24, 2024

The only way to properly add a form-data file to a request in urllib3 is by encode_multipart_formdata (filepost.py), there it writes the entire body of the outgoing request to a StringIO object, hence it pushes all of the file's contents in it.
httplib's send() will read/write this object block-by-block, but that doesn't help when the object is created this way.

from urllib3.

jtolio avatar jtolio commented on August 24, 2024

Gotcha. Yeah, multipart formdata is totally different than sending the file data directly in the body. I suppose that does require urllib3 support.

Of course, you could generate the request body data object yourself. It shouldn't be too difficult to make a file-like object that wraps a few files with some multipart formdata formatting business logic.

from urllib3.

shazow avatar shazow commented on August 24, 2024

There's an old stale branch where I tried to do this but I abandoned it due to too many edge cases. Might be worth taking another crack at it.

from urllib3.

shazow avatar shazow commented on August 24, 2024

I've added some more filepost tests to cover some of the edge cases, but I think there are a lot more: 5b1a8b7

@allover are you interested in taking a crack at this issue?

from urllib3.

shazow avatar shazow commented on August 24, 2024

This would be nice to have, anyone interested in working on it? (bump)

from urllib3.

sethmlarson avatar sethmlarson commented on August 24, 2024

This is being worked on in #1030

from urllib3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.