Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
October 7, 2004, 10:47 pm
rate this thread
request variable/object?. The code works fine, but for visual clarity
it would be nice to merge the cookies line into some other line if
possible.(I love Perl because it still has a good old thing called
procedural programing, OO stuff is chinese to me).
my $ua = new LWP::UserAgent;
my $request = HTTP::Request->new('GET', $my_url);
$request->header('Cookie' => 'foo_likes_it=hi');
my $response = $ua->request($request);
Also, less importantly (remember TMTOWTDI), did I do the right thing
by adding a static cookies header to the HTTP request? or should the
professional way be through the cookie_jar of LWP::UserAgent, and then
to HTTP::Cookies, or play with HTTP::Headers?
The cookie is always static, and never needs to be changed. There is
no need to "save" or "capture" any cookies from the server.
Re: need some visual clarity/implimentation LWP help
Quoth email@example.com (buildmorelines):
(my $req = H:R->new())->header();
I would *never* write a cookies header by hand. I would use
HTTP::Cookies->set_cookie and HTTP::Cookies->add_cookie_header.
[I would also attempt to learn how to type 'cookie' without it coming
out as 'cooiek' ;) ]
"If a book is worth reading when you are six, * firstname.lastname@example.org
it is worth reading when you are sixty." - C.S.Lewis