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.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; } }
In reply to Unable to access restricted URL resource (GET) 302 redirect msg - using HTTP::Request::Generator by asadzzz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |