Hi Folks, I'm using https://metacpan.org/pod/HTTP::Request::Generator to generate multiple GET resource which is password protected. So my plan is to first use POST followed up with GET request.
use strict; use warnings; use HTTP::Request::Generator 'generate_requests'; use LWP::UserAgent; use LWP::Protocol::https; use Data::Dumper; use Test::More; my $ua = 'LWP::UserAgent'->new(max_redirect => 3); my $gen = generate_requests( method => 'POST', host => [ 'abc.ai' ], #pattern => 'https://abc.ai', # port => '443', scheme=> ['https'], path=>'/login', #url => '/login/', body_params => { user_id => ['dem'], user_password=> ['dem'], }, headers => { "User-Agent" => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64', "TE" => "application/json", "Cookie" => 'abc', }, wrap => sub { my ( $req ) = @_; # $req->{headers}->{'TE'} = 'ASAD'; return $req; }, wrap => \&HTTP::Request::Generator::as_http_request, ); while ( my $req = $gen->() ) { my $response = $ua->request( $req ); print $response->protocol, ' ', $response->status_line, "\n"; # print $req->headers->as_string, "\n"; print $response ->header('title',"\n"); print $req->headers->as_string, "\n"; #print $response ->header('title',"\n"); #print $response->content,"\n"; # Do something with $response here? if ($response->is_success) { # print $response->decoded_content; print $response ->header('title',"\n"); } else { print $response->status_line; } }
I'm getting 302 I want to know how can I marshal above code to perform GET request after POST, do I need to create another LWP object. Thanks.

In reply to Unable to access restricted URL resource (GET) 302 redirect msg - using HTTP::Request::Generator by asadzzz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.