Bump. Am I creating cookies correctly?
Cheers, Warren > On 15 Aug 2017, at 03:34, Warren Humphreys <[email protected]> wrote: > > Hi, > > I’m attempting to talk to a slightly unusual API using Mojo::UserAgent; > > To authenticate I first have to post an XML payload, the response to which is > another XML payload containing some cookies that I need to set to continue to > talk to the API. > To be clear the cookie values come back in the response XML payload, they are > not set as response cookies. > > I can process the DOM just fine and extract the cookie values, but if I add > them to the useragent cookie_jar before my next request the Cookie header > isn’t set to contain the values in the jar. > > > So if I do this: - > > POST request and get payload, then > > my $coookies = ''; > > for my $cookie ($res—>dom—>find('cookie')—>each) { > $ua—>cookie_jar—>add( > Mojo::Cookie::Response—>new( > name => $cookie—>attr('name'), > domain => $cookie—>attr('domain'), > path => $cookie—>attr('path'), > value => $cookie—>text > ) > ); > > $cookies .= $cookie—>attr('name'); > $cookies .= '='; > $cookies .= $cookie—>text; > $cookies .= ';'; > } > $tx = $ua—>post($APIURL => {Accept => 'application/json', 'Content—Type' => > 'application/json', 'Cookie' => $cookies} => $request ); > > Manually including the Cookie header in the request works, anything else > doesn’t. > > I’m probably missing something obvious, but its driving me mad. > > > -- > 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 https://groups.google.com/group/mojolicious. > For more options, visit https://groups.google.com/d/optout. -- 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 https://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.
