in reply to Re: LWP Credentials Login Problem to Download Zip Files
in thread LWP Credentials Login Problem to Download Zip Files

It worked. I've gained access, but now I'm running into problems returning the file itself. I get the response of 200, which is great, but I would like it to prompt me to save the file. What am I doing wrong?
use LWP::UserAgent; use HTTP::Request::Common; my $filename = 'file.zip'; # example my $url = "http://www.domain.com/$filename"; my $ua = LWP::UserAgent->new(keep_alive=>1); my $headers = HTTP::Headers->new(); $headers->authorization_basic('user', 'pass'); my $request = new HTTP::Request(GET => $url, $headers); my $response = $ua->request($request); print "response:" . $response->code . "<br>"; open(ZIP, ">$filename"); binmode ZIP; print ZIP $response->content; close(ZIP);

Replies are listed 'Best First'.
Re^3: LWP Credentials Login Problem to Download Zip Files
by ikegami (Patriarch) on Aug 26, 2004 at 16:40 UTC

    I don't quite understand the question. That code works for me (although you might want to check if open() returns an error).

    Are you asking how to ask the user for a file name? You could use Perl/Tk for a dialog-based approach, or here's a unrefined console-based approach:

    print("Enter local filename, or just Enter to abort: "); my $local_filename = <STDIN>; chomp($local_filename); if ($local_filename ne '') { open ... }