I'm having strange behavior on several fronts.

First, when I capture the actual web traffic, it's the same (almost) for both my browser, and for LWP, except that the packets captured by Ethereal when using the browser suddenly stop in the middle of the transmission. With LWP, you see the entire first web page; with the browser (Firefox 2), it ends like this:

function yadda(... // check for redirection return redirectCheck(pluginFound, redire
Consistently, it cuts off receiving after "redire" in Firefox, although it receives the entire TCP stream when using Internet Explorer. This is not a cache issue; I cleared the cache before trying with both browsers.

Second, LWP handles the redirect automatically - as evidenced by the fact that, although the headers that Ethereal sees say

HTTP/1.1 302 Object Temporarily Moved Connection: close Date: Sun, 01 Jul 2007 03:53:25 GMT Server: Microsoft-IIS/6.0 location: https://<...etc>
LWP's $response->status_line returns only "200 OK". However, that "200 OK" response is not captured by Ethereal. My program receives it, but Ethereal claims it's never been received over port 80. AND, LWP does not receive the redirected page in the response. Neither does the response contain the original page. The response that LWP saves is some third page, neither the original, nor the page redirected to.

Third, the web browser continues on to display the next webpage, even though no more traffic was captured by Ethereal.

The code looks like this:

my $ua = LWP::UserAgent->new( requests_redirectable => [ 'GET', 'HEAD', 'POST' ] ); ... $response = $ua->get($uri, @headers); # Handle redirects # This code never actually executes - LWP does it automati +cally # That's why you never see the redirect message while ($response->is_redirect) { my $location = $response->header("location"); print " "x$level . "Redirected to $location\n"; $response = $ua->get($location); } $page = $response->content; $success = $response->is_success; if (!$success) { print "LWP ERR: " . $response->status_line . "\n"; }
Am I supposed to use LWP::Redirect? I find there is a module of that name, but no documentation mentions it.

In reply to Re^2: LWP and Site Logins by shagbark
in thread LWP and Site Logins by debiandude

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.