Re: Upload callback -- chunking an upload.

Tim Brody <[email protected]> Thu, 17 Jan 2013 11:39:40 +0000
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <EMEW3|05899a40d6dde53ff07d722c2999704ep0GBk704tdb2|ecs.soton.ac.uk|[email protected]>
On Wed, 16 Jan 2013 21:44:40 -0800, Bill Moseley <[email protected]> wrote=
:
> I need to do some upload testing where I can control the chunk size and
> rate of an upload.    So, what I'd like is to use a sub ref that is
called
> for each chunk that is uploaded.
>=20
> I'm not very clear from the docs in HTTP::Request::Common if
> $DYNAMIC_FILE_UPLOAD
> can be used for that -- doesn't seem so. That seems more for seeing how
> much data has been uploaded from a file (e.g. a progress meter).
>=20
> Is there a way to chunk upload a form-data request from a sub ref using
> LWP? Somewhat of the opposite of the content_cb for a response.
>=20
> Thanks,

Hi,

(Untested) I believe you can supply a CODEREF to the request content and,
if you don't set a Content-Length header, the request will be a TE-chunke=
d
upload:

$req =3D HTTP::Request->new( POST =3D> 'http://www.example.com/', undef, =
sub {
return <STDIN>;
});

--=20
All the best,
Tim.