in reply to HTTP response buffer

Why not just use LWP::UserAgent, and the ->get method with a :content_cb callback? That way you can keep the user updated while you still get a full-blown HTTP client.

Replies are listed 'Best First'.
Re^2: HTTP response buffer
by nevafuse (Novice) on Feb 23, 2009 at 21:11 UTC
    That sorta works. The file is a wav audio file, and when I print out the $data from the callback to a new file, it isn't opening. Do you think I need to convert the $data into a different format?
    $browser = LWP::UserAgent->new(); my $resp = $browser->get($url,':content_cb' => sub { my($data, $resp) = @_; open FILE, ">>1.wav" or die $!; print FILE $data; close FILE; return; },':read_size_hint' => 1024);

      You should binmode the file after opening it. I wouldn't reopen the file on every run through:

      open my $fh, '>', $filename or die "Couldn't create '$filename': $!"; binmode $fh; $browser = LWP::UserAgent->new(); my $resp = $browser->get($url,':content_cb' => sub { my($data, $resp) = @_; print $fh $data; return; },':read_size_hint' => 1024); close $fh;
        I love you?