Skip to content

Instantly share code, notes, and snippets.

@marcusramberg
Created June 19, 2013 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcusramberg/5813679 to your computer and use it in GitHub Desktop.
Save marcusramberg/5813679 to your computer and use it in GitHub Desktop.
my $tx = $self->ua->build_tx(POST => $url);
$tx->req->headers->content_length($file->size);
my $offset = 0;
my $chunk_size = 4096;
my $drain;
$drain = sub {
my $req = shift;
my $chunk = $file->get_chunk($offset, $chunk_size);
$drain = undef unless length $chunk;
$offset += length $chunk;
$req->write($chunk, $drain);
};
$tx->req->$drain;
$self->ua->start($tx, $delay->begin);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment