Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: LWP::UserAgent doesn't send my HTTP::Cookies

by shmem (Chancellor)
on Jul 01, 2016 at 18:49 UTC ( [id://1167016]=note: print w/replies, xml ) Need Help??


in reply to LWP::UserAgent doesn't send my HTTP::Cookies

The difference between the version which doesn't

# Show this #!? cookie print Dumper $cookie if $option->{verbose}; # list archives $request = HTTP::Request->new( GET => "https://$option->{hostname}/storiqone-backend/api/v1/archi +ve/" ); $request->content_type('application/json');

and the version which just frigging works

# list archives $request = HTTP::Request->new( GET => "https://$option->{hostname}/storiqone-backend/api/v1/archi +ve/" ); $request->content_type('application/json'); $request->header('Cookie' => $cookie);

is that in the former you don't add the cookie to the request header, but in the latter you do. What do you expect? Do you expect that $ua shoehorns its cookie-jar into the new HTTP::Request object? You are expecting too much magic, I guess ;-)

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^2: LWP::UserAgent doesn't send my HTTP::Cookies
by Anonymous Monk on Jul 01, 2016 at 19:29 UTC

    What do you expect? Do you expect that $ua shoehorns its cookie-jar into the new HTTP::Request object? You are expecting too much magic, I guess ;-)

    Yeah, $ua will absolutely take cookies from the cookiejar and add them to any requests, if they exist

      That's why I mention that the cookie is displayed, therefore it exists :)

        Most likely you can easily swap out WWW::Mechanize for your hand-rolled version of the user agent. If it works with WWW::Mechanize, then something is weird in your cookie handling.

        You haven't shown whether the cookie has some path or something that would restrict it from being sent. See below for code by Anonymous Monk that outputs some more debug information.

Re^2: LWP::UserAgent doesn't send my HTTP::Cookies
by wazoox (Prior) on Jul 05, 2016 at 11:24 UTC

    The LWP::UserAgent and lwpcook documentations seem to imply that yes, cookies are automagically inserted in headers if the cookie_jar has been set up.

    Of course adding explicitly the cookie object to the headers has absolutely no effect...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1167016]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-03-29 06:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found