I'm using:
my $ua=Mojo::UserAgent->new();
$ua->on(start => sub {
my ($ua, $tx)=@_;
$tx->req->headers->header("accept" => "application/json");
$tx->req->url->scheme("http");
$tx->req->url->host("localhost");
$tx->req->url->port("3000");
});
In my script to make my life easier interacting with a RESTful service.
I then call:
$ua->post("/authenticate" => json => { "user" => $user, "password" =>
$password });
Which responds with a 'set-cookie' header.
I can verify that $ua->cookie_jar contains the cookie that was sent.
I make a subsequent call to:
$ua->post("/edit")
However the cookie data is not sent in the request header.
If I strip out the 'on start' code, the cookie is handled as I would expect
(included in the request header to edit).
Did I miss something? Is this a poor use of the 'on start' technique and
should be avoided?
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/groups/opt_out.