axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Axiom-developer] Re: Axiom HyperDoc Replacement


From: Bill Page
Subject: RE: [Axiom-developer] Re: Axiom HyperDoc Replacement
Date: Sat, 21 Apr 2007 13:05:01 -0400

Martin,

On April 21, 2007 11:45 AM you wrote:
> 
> There appear to be at least two different errors in the code below.
> 
> (defun server (s)
>   (let* ((get (read s nil 'eof))
>          (fn (and (eq get 'get) (read s nil 'eof))))
>     (format t "Got ~S~%~%" fn)
>     (format s "HTTP/1.1 ~S~%" (if fn 303 403))
>     (format s "Location:
>   file:/users/rubey/martin/Axiom/hyperdoc-replacement/stretch.html~%")
>     (close s)))
> 
> gives
> 
> An error occurred while loading http://localhost:8080/x:
> Access denied to 
> file:///users/rubey/martin/Axiom/hyperdoc-replacement/stretch.html.

Don't be too easily discouraged. Because it is a communications
protocol it is necessary to get it *exactly* right for everything
to function. But once it is working, you wont have to change it.

I think file:///... (with 3 slashes) is the correct form.

http://en.wikipedia.org/wiki/File:_URL

The "host name" goes between the 2nd and 3rd / just like in a
normal http://goggle.com/... the hostname part is omitted in the
case of localhost (but keep the extra /).

To find out the exactly correct local path for this file, try
opening using the the top menu File/Open File. Select the file
by browsing and then open it. The url displayed in the address
line is what you need to send from the server. Here an example
that works with FireFox on my system:

file:///C:/Documents%20and%20Settings/Administrator.ASUS/My%20Documents/2519
4756_B_store.jpg

Notice that the drive letter C: is the first thing after ///
and also that spaces must be converted to %20 codes.

> 
> (defun server (s)
>   (let* ((get (read s nil 'eof))
>          (fn (and (eq get 'get) (read s nil 'eof))))
>     (format t "Got ~S~%~%" fn)
>     (format s "HTTP/1.1 ~S~%" (if fn 303 403))
>     (format s "Location: http://mat.univie.ac.at";)
>     (close s)))
> 
> seems to work
>

Great.
 
> (defun server (s)
>   (let* ((get (read s nil 'eof))
>          (fn (and (eq get 'get) (read s nil 'eof))))
>     (format t "Got ~S~%~%" fn)
>     (format s "HTTP/1.1 ~S~%" (if fn 303 403))
>     (format s "Location: ~S~% "http://mat.univie.ac.at";)
>     (close s)))
> 
> gives "Got /" forever.
> 
> Please Help!
> 

That's a syntax error. The string "Location: ~S~%" is a
format. ~S is replaced with a string, ~% is replaced with
a line feed (new line). After the format string comes the
data for the substitutions. So you need:

     (format s "Location: ~S~%" "http://mat.univie.ac.at";)

If you key the following at the Lisp (i.e. Boot prompt in
Axiom),

     (format t "Location: ~S~%" "http://mat.univie.ac.at";)

You should get exactly the same result as this one with no
substitutions.

     (format t "Location: http://mat.univie.ac.at";)

except for an extra blank like.

where t stands for the constand "true" and represents the
'standard out' stream. I recommend you test the format
first with t and later change it to s.

Regards,
Bill Page






reply via email to

[Prev in Thread] Current Thread [Next in Thread]