in reply to [Solved] WWW::Mechnize redirect handling

shouldn't you be using $m->max_redirect(0); in order to get the headers of your first hit, checking if indeed you get a 302 status, then extract the token from headers of first URL and head for the login url?

bw, bliako

Replies are listed 'Best First'.
Re^2: WWW::Mechnize redirect handling
by nikster (Novice) on Nov 22, 2019 at 18:20 UTC
    Hi and thanks for your reply. I tried that (a minute ago), but the response stays the same.

      can you show the code? and the response?

        Yes, of course, but I've just changed:

        $m->max_redirect(2);

        to:

        $m->max_redirect(0);

        On a closer look, the result is not entirely the same but also not much better (redirect loop detected):

        Cache-Control: no-cache, no-store, max-age=0, must-revalidate Date: Fri, 22 Nov 2019 22:25:09 GMT Pragma: no-cache Via: url Server: servername Vary: Accept-Encoding,Origin Content-Encoding: gzip Content-Language: en Content-Length: 6336 Content-Type: text/html;charset=UTF-8 Expires: 0 Client-Date: Fri, 22 Nov 2019 22:29:13 GMT Client-Peer: xxx.xxx.xxx.xxx:443 Client-Response-Num: 1 Client-SSL-Cert-Issuer: /certinfo Client-SSL-Cert-Subject: /certinfo Client-SSL-Cipher: ECDHE-RSA-AES256-GCM-SHA384 Client-SSL-Socket-Class: IO::Socket::SSL Client-SSL-Warning: Peer certificate not verified Client-Warning: Redirect loop detected (max_redirect = 0) Strict-Transport-Security: max-age=15768000 ; includeSubDomains Strict-Transport-Security: max-age=15768000 X-Content-Type-Options: nosniff X-Frame-Options: DENY X-XSS-Protection: 1; mode=block

        Strange, isn't it?