I'm working on a Perl script that has to retrieve a file from a server. The server requires authentication that is handled internally by a different server. What I need to do to retrieve the file, is to first, POST to an authenticating server, which will return two cookies. I then need to send these cookies via a GET to the target server that has the file I need. I'm looking about the net and even here for examples, but I'm still unclear on how to go about this. Can someone show me an example of how to do this?
Asked
Active
Viewed 145 times
2 Answers
2
To make an LWP::UserAgent
object that implements cookies is as simple as this:
my $ua = LWP::UserAgent->new();
$ua->cookie_jar({});
See this article for more examples.

Eugene Yarmash
- 142,882
- 41
- 325
- 378
-1
You can certainly use Net::HTTP and look at the returned headers to pull the cookies out, then feed them back when you use write_request(), but this is hardly convenient.

Seth Robertson
- 30,608
- 7
- 64
- 57