Try using telnet to interact with the web server. I typed "GET /clients
HTTP/1.0" (enter) (enter)
As you can see below a Location: header is present and the status code is
301. Hope this helps,
-Tony
[tony@... clients]$ telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /clients HTTP/1.0
HTTP/1.1 301 Moved Permanently
Date: Sat, 24 Jun 2000 22:51:27 GMT
Server: Apache/1.3.9 (Unix) (Red Hat/Linux) mod_fastcgi/2.2.2
Location: http://www.nationsprint.com/clients/
Connection: close
Content-Type: text/html
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>301 Moved Permanently</TITLE>
</HEAD><BODY>
<H1>Moved Permanently</H1>
The document has moved <A
HREF="http://www.nationsprint.com/clients/">here</A>.<P>
<HR>
<ADDRESS>Apache/1.3.9 Server at http://www.nationsprint.com Port 80</ADDRESS>
</BODY></HTML>
Connection closed by foreign host.
At 07:37 PM 6/24/00 -0400, Chuck Esterbrook wrote:
>I wrote a quick script, ReadURL, which uses sockets (instead of urllib) to
>read a URL so I could see a raw response with no interpretation. As
>discussed earlier on the Webware list, web servers that get a request for:
>http://host/somedirectory Send back a redirect for:
>http://host/somedirectory/ in order that relative URLs in the resulting
>page will work correctly when the user clicks on them. In order to test
>this, I created a directory foo/ on my local machine and requested
>http://localhost/foo. What I got was this: #--begin Sending request: GET
>/foo... Sent. Reading response... Read 291 bytes. Read 0 bytes. Read.
>Contents:
>
>Moved Permanently
>
>The document has moved <http://localhost/foo/>here.
>
>
>----------
>Apache/1.3.12 Server at localhost Port 80 Done. #--end The "Contents:"
>part is everything that I get from the socket and as far as HTML goes, it
>looks like what I would expect Apache to return. However, I also expected
>some kind of HTTP headers right before it like: Status: 301 Redirect:
>http://localhost/foo/ However, I don't see this. Anyone know what code or
>concept I'm missing here? My program is playing the part of the browser,
>but I don't see how it's supposed to know the HTTP status code or anything
>else. I also get the same results with telnet. I'm using Apache 1.3.x on
>Windows. If it helps, here's an excerpt of the code. I'll send the whole
>thing if need be. s = socket(AF_INET, SOCK_STREAM) s.connect(host, port)
>request = 'GET /foo' print 'Sending request: %s...' % request
>s.send(request+'\r\n\r\n') print 'Sent.' s.shutdown(1) # read the raw
>reponse (which is a marshalled dictionary) print 'Reading response...'
>response = '' while 1: chunk = s.recv(bufsize) print 'Read %d bytes.' %
>len(chunk) if not chunk: break response = response + chunk print 'Read.'
>
>
>------------------------------------------------------------------------
>Old school buds here:
>http://click.egroups.com/1/5545/0/_/_/_/961889954/
>------------------------------------------------------------------------
>
>To unsubscribe from this group, send an email to:
>python-web-modules-unsubscribe@...
>
>
|