简体   繁体   中英

Stream large http response to disk in Erlang with httpc lib

httpc:request(get, {URL, []}, [], [{stream, FilePath}]) returns {ok, saved_to_file} even when the remote web-service dies midway while streaming the response. I checked the content on the disk was missing a whole bunch of data. Is this a known quirk and expected?

I filed a bug-report and the answer from OTP team indicated it was a bug (atleast for the current HTTP spec):

I think this is due to that the client has backwards compatibility with servers that would close the connection to indicate that all data has been sent. Probably this should be made conditional for only old versions of the HTTP protocol or maybe it could be dropped... - Ingela Anderton Andin

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM