Lisp HUG Maillist Archive

HTTP problem

I'm trying to use the example from 
http://www.lispworks.com/reference/lw43/LWRM/html/lwref-27.htm to 
download the www.lispworks.com main page. Instead of downloading the 
page I've got the following:

HTTP/1.1 301 Moved Permanently
Date: Sat, 03 Apr 2004 19:03:10 GMT
Server: Apache/2.0.39 (Win32)
Location: http://www.xanalys.com/
Content-Length: 305
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a 
href="http://www.xanalys.com/">here</a>.</p>
<hr />
<address>Apache/2.0.39 Server at www.zanalys.com Port 80</address>
</body></html>


Is it a bug in the documentation? What should I do to download the 
proper page? I'm not very familiar with the http.

Thanks,

Michal


Re: HTTP problem

Michal,

On Apr 3, 2004, at 2:10 PM, Michal Krupka wrote:

> Is it a bug in the documentation? What should I do to download the 
> proper page? I'm not very familiar with the http.
>
>

You have done nothing wrong. This is a standard HTTP response that 
means the page you requested has been moved. If you were using a 
browser it would automatically redirect you to the address in the 
Location: header. So just request www.xanalys.com in your request to 
get the main page.

Best,

John DeSoi, Ph.D.


Re: HTTP problem

On Sun, 4 Apr 2004 11:10:30 +0200, Michal Krupka <MichalKrupka@mac.com> wrote:

> John,
>
> On 4.4.2004, at 4:45, John DeSoi wrote:
>>
>> You have done nothing wrong. This is a standard HTTP response that
>> means the page you requested has been moved. If you were using a
>> browser it would automatically redirect you to the address in the
>> Location: header. So just request www.xanalys.com in your request
>> to get the main page.
>
> Thank you for your response, but I want to download the
> www.lispworks.com page rather than the www.xanalys.com page.
>
> The code from the example:
>
> (with-open-stream (http (comm:open-tcp-stream
>                           "www.lispworks.com" 80))
>    (format http "GET / HTTP/1.0~C~C~C~C"
>                 (code-char 13) (code-char 10)
>                 (code-char 13) (code-char 10))
>    (force-output http)
>    (write-string "Waiting to reply...")
>    (loop for ch = (read-char-no-hang http nil :eof)
>          until ch
>          do (write-char #\.)
>             (sleep 0.25)
>          finally (unless (eq ch :eof)
>                    (unread-char ch http)))
>    (terpri)
>    (loop for line = (read-line http nil nil)
>          while line
>          do (write-line line)))

Looks like Xanalys has changed their server settings and hasn't
updated their example. I guess www.lispworks.com is now a 'named
virtual host' on the same server that also runs www.xanalys.com. So
this is likely to work:

(with-open-stream (http (comm:open-tcp-stream
                          "www.lispworks.com" 80))
   (format http "GET / HTTP/1.0~C~CHost: www.lispworks.com~C~C~C~C"
                (code-char 13) (code-char 10)
                (code-char 13) (code-char 10)
                (code-char 13) (code-char 10))
   (force-output http)
   (write-string "Waiting to reply...")
   (loop for ch = (read-char-no-hang http nil :eof)
         until ch
         do (write-char #\.)
            (sleep 0.25)
         finally (unless (eq ch :eof)
                   (unread-char ch http)))
   (terpri)
   (loop for line = (read-line http nil nil)
         while line
         do (write-line line)))

The example code didn't send a 'Host' header and thus you were
redirected to Apache's 'default host' - my guess...

Edi.


Re: HTTP problem

On Sun, 4 Apr 2004 11:33:04 +0200, Sven Van Caekenberghe <sven@beta9.be> wrote:

> www.lispworks.com is a virtual host. The Host: request header is
> required for HTTP/1.1 I believe.

AFAIK this is not exactly correct. The example explicitely states
HTTP/1.0 for the protocol and the conversation is done in
HTTP/1.0. It's just that Apache's 'name-based virtual hosts' (several
hosts with different names using the same IP address) don't work
unless the client sends a 'Host' header. This is a reasonable approach
taken by the Apache guys because virtually every browser has sent
'Host' headers for years although very few implemented the full
HTTP/1.1 protocol.

Edi.


Updated at: 2020-12-10 08:57 UTC