Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

is it possible to send post request whose content comes from file?
to avoid bumping up memory usage?

$ua = LWP::UserAgent->new(); $req = HTTP::Request->new(POST=> $post_url); $res = $ua->request($req, 'response_file.dat');

Replies are listed 'Best First'.
Re: http post requst content from file
by roboticus (Chancellor) on Feb 17, 2010 at 14:24 UTC

    Not really, as the file needs to be read into memory anyway to be sent to the recipient. You could play with it, but you'd merely be moving around the code that ultimately performs the read.

    ...roboticus

      There also is IO::Sendfile and Sys::Sendfile, which avoid some of the buffers data is copied through while being read from disk and sent through a socket. Your OS needs to support some kind of sendfile API for that though and the module needs to support that flavour of OS.

Re: http post requst content from file
by Anonymous Monk on Feb 17, 2010 at 15:15 UTC