Problem with libwww and HTTP 200, HTTP 302 response messages 
Author Message
 Problem with libwww and HTTP 200, HTTP 302 response messages

I'm issuing the following GET method to a
server trough libwww:

require LWP::UserAgent;
require HTTP::Request;
require HTTP::Headers;

my $UserAgent = new LWP::UserAgent;
my $hdr1 = new HTTP::Headers;
$UserAgent->agent('Mozilla/2.0 (compatible; MSIE 3.02; Update a; AK;
Windows 95)');
        $hdr1->header(Connection => 'Keep-Alive',
                        Host => 'www.soldionline.it',
                        Accept => 'image/gif, image/x-xbitmap,
image/jpeg, image/pjpeg, */*',
                        Referer => ' http://www.*-*-*.com/ ');
my $request = new HTTP::Request('GET',
' http://www.*-*-*.com/ ', $hdr1);
my $response = $UserAgent->request($request);

If I  print $request->as_string,  I have

GET http://www.*-*-*.com/
Connection: Keep-Alive
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Host: www.soldionline.it
Referer: http://www.*-*-*.com/
User-Agent: Mozilla/2.0 (compatible; MSIE 3.02; Update a; AK; Windows
95)

Like response I have :

HTTP 200 OK

Connection: close
Date: Sun, 16 Jan 2000 14:31:25 GMT
Accept-Ranges: bytes
Server: Apache/1.3.6 (Unix) ApacheJServ/1.0
Content-Length: 4012
Content-Type: text/html
ETag: "8bfa2-fac-38301445"
Last-Modified: Mon, 15 Nov 1999 14:10:13 GMT
Client-Date: Sun, 16 Jan 2000 11:29:46 GMT
Client-Peer: 127.0.0.1:2222
Title: SoldiOnline Daily

If I issue the same request trough a proxy I have the same result
on print response->as_string (HTTP 200 OK), but if I see the log of
the
proxy I can see something like

T4 01/13 21:39:48 Server Data: HTTP/1.1 302 Found{0D}{0A}
T4 01/13 21:39:48 Server Data: Date: Thu, 13 Jan 2000 23:41:33
GMT{0D}{0A}
T4 01/13 21:39:48 Server Data: Server: Apache/1.3.6 (Unix)
ApacheJServ/1.0{0D}
T4 01/13 21:39:48 Server       {0A}
T4 01/13 21:39:48 Server Data: Set-Cookie:
JServSessionId=3fdf98ba6557a620.40405
T4 01/13 21:39:48 Server       5.947806893500; path=/{0D}{0A}
T4 01/13 21:39:48 Server Data: Location:
http://www.*-*-*.com/
T4 01/13 21:39:48 Server       ione.html{0D}{0A}
T4 01/13 21:39:48 Server Data: Connection: close{0D}{0A}
T4 01/13 21:39:48 Server Data: Content-Type: text/html{0D}{0A}
T4 01/13 21:39:48 Server Data: {0D}{0A}

I mean a 302 Redirection.

If I issue the same request trough a browser like Netscape 3.0 I
receive
a 302 redirection anyway (with or without  the proxy)

Does someone knows why I have a 200 instead of a 302 response ?

Thank you in advance

Massimiliano



Wed, 18 Jun 1902 08:00:00 GMT  
 Problem with libwww and HTTP 200, HTTP 302 response messages

Quote:
> Could someone tell me  why I have a 200 instead of a 302 response ?

Because the server is configured to redirect you to
<URL:http://www.soldionline.it/rap/registrazione.html>

What would you like libwww to do such cases? You will find further
information in RFC2068 and successors.

Ben.



Wed, 18 Jun 1902 08:00:00 GMT  
 Problem with libwww and HTTP 200, HTTP 302 response messages

Quote:

> I'm issuing the following GET method to a
> server trough libwww:

> require LWP::UserAgent;
> require HTTP::Request;
> require HTTP::Headers;
[snip]
> Like response I have :

> HTTP 200 OK
[snip]
> If I issue the same request trough a browser like Netscape 3.0 I
> receive a 302 redirection anyway (with or without  the proxy)

> Does someone knows why I have a 200 instead of a 302 response ?

You are probably seeing just the final status ... that of the
successful redirect. Try the following bit to see what's actually
happening:

#!/usr/bin/perl

use LWP::UserAgent;
use LWP::Debug qw(+conns);

$URL = 'http://www.soldionline.it/quotazioni/02.rtq';

$ua = LWP::UserAgent->new;
$request = HTTP::Request->new(GET => $URL );
$response = $ua->request($request);

__END__

This should show you everything that's happening.

Hope that helps

Pat
--
$monger{Omaha}[0]
Patrick Timmins

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. HTTP::Response: Getting the HTTP header

2. Bad header=HTTP/1.1 200 OK

3. Bad header=HTTP/1.1 200>

4. Errors in HTTP/Response & LWP/Response

5. http::response problem (still - sorry)

6. problem with http:request and response: any ideas????

7. problem with http:response and request classes

8. libwww-perl: Specifying HTTP Version Problem

9. libwww-perl-5.01: bug calling HTTP::Response::base from HTTP::Request callback?

10. 302 Moved Message from Apache

11. HTTP::Response when client dies

12. Parse HTTP RESPONSE Headers Active Perl CGI

 

 
Powered by phpBB® Forum Software