cmullaparthi / ibrowse

Erlang HTTP client
Other
516 stars 190 forks source link

Support for asynchronous request data #92

Open egirshov opened 11 years ago

egirshov commented 11 years ago

I'm targeting use case when body is not fully available at the time of making request. Adding new option 'stream_request' (should be used together with 'stream_to' for response)

cmullaparthi commented 11 years ago

Hi, have you looked at whether you can use the option to supply a fun for the Body? That fun can be used to generate the body after a request is submitted.

egirshov commented 11 years ago

Yes, I did. I found this way more convenient, but if you believe there is no need to have anything besides fun as a body, I would not argue. 125fe14 or a similar fix for tracing could be still considered.

cmullaparthi commented 11 years ago

I've read the patch more closely. It looks good and I like it. Thank you. A couple of questions/suggestions if I may.

get_value(stream_to, Options, undefined) =/= undefined.

rather than defining a new option?

egirshov commented 11 years ago

I introduced new option deliberatly to make it possible in the future for both request and response to be sent complete or in chunks. Otherwise, if we want 'streaming request' to imply 'streaming response' I could change line 984 as you suggested (but then use for example 'undefined' value for the Body as an indication of send_chunk/send_done interface).

Regarding timeouts - currently if no send_done is called ever, request will fail with ibrowse_async_response_timeout (when corresponding timeout expires).