LispOS: LispEnv or Tunes?

Rainer Joswig joswig@lavielle.com
Sat, 3 May 1997 00:39:26 +0200


At 12:32 Uhr -0700 2.5.1997, Kelly Murray wrote:


>I believe SilkScript is *easy* to learn -- you don't need to know
lisp

>already to use it.

>This is the problem with CL-HTTP - you have to be a lisp expert to
use

>it, and I believe it actually makes everything MORE complicated

>instead of simpler.


CL-HTTP implements a complete infrastructure for doing web things.

It tries to actually handle HTTP. It does support all

the HTTP stuff and more. HTTP *is* complicated.


It handles for example the HEAD command.


Take this CL-HTTP code for getting the modified date

of a page.


(defun <bold>get-url-modified-date</bold> (url headers)

  (handler-case

    (http::handling-redirects (url)

      (http::handling-authentication (authorization)

        (http:with-http-request

          (url :head 

               :request-headers
(http::compute-standard-request-headers

                                 url

                                 :authorization authorization

                                 :header-plist headers))

          http::remote-stream				;ignore 

          (http::with-status-code-dispatch (:client http::client

                                            :url url

                                            :status
(http::client-status http::client))

            (http:get-header :last-modified http::*headers*)))))

    (http::http-condition (cond) cond)))



? <bold>(http-user::get-url-modified-date (url:url
"http://wilson.ai.mit.edu/") nil)

</bold>3064249727

T


? <bold>(http-user::get-url-modified-date (url:url
"http://www.franz.com/") nil)

</bold>#<<HTTP::DOCUMENT-NOT-FOUND #x2DB8ABE>


I mean, by implementing only the parts of HTTP/HTML my web server would
look

simpler, too. I just would like to have a MODIFIED header as a response
to

a HEAD request to see whether your page has changed without actually

getting the page itself.



CL-HTTP has a lot of features that will make dealing at a programmer

level with HTTP simpler. If you want to create own services on top

of CL-HTTP you sure may implement libraries which makes it easier

for less experienced people. In my own code I just

end up doing MAKE-INSTANCE on page objects:


(defparameter *explanations-page*

  (make-instance 'als-explanations-page

    :title "Begriffe"

    :url #u"/als/begriffe"

    :body-function 'als-explanations

    :file (pathname "als:Leasingbegriffe;Begriffe.tabdel")

    :search-url #u"/als/begriff?"))


With a body function like this:


(defmethod als-explanation ((page als-explanation-page) url stream)

  (let* ((explanation-word-string (and (url:search-keys url)

                                       (string-trim '(#\space #\tab)

                                                    (first
(url:search-keys url)))))

         (explanation (find explanation-word-string *explanations*

                            :key #'explanation-word-string

                            :test #'equalp)))

    (princ "Alle Begriffe: " stream)

    (html:note-anchor "&Uuml;berblick"

                      :stream stream

                      :reference "/als/begriffe")

    (html:break-line :stream stream)

    (when (explanation-previous explanation)

      (princ "Vorheriger Begriff: " stream)

      (html:note-anchor (explanation-word-string (explanation-previous
explanation))

                        :stream stream

                        :reference (concatenate

                                    'string "/als/begriff?"

                                    (explanation-word-string

                                     (explanation-previous
explanation)))))

    (html:break-line :stream stream)

    (when (explanation-next explanation)

      (princ "N&auml;chster Begriff: " stream)

      (html:note-anchor (explanation-word-string (explanation-next
explanation))

                        :stream stream

                        :reference (concatenate

                                    'string "/als/begriff?"

                                    (explanation-word-string

                                     (explanation-next
explanation)))))

    (html:break-line :stream stream)

    (html2:with-section-heading ((explanation-word-string explanation)
:level 2 :stream stream)

      (loop for sentence in (explanation-sentences-strings
explanation)

            do (or (maybe-insert-explanation-anchor sentence "Siehe: "
stream)

                   (maybe-insert-explanation-anchor sentence "Siehe
auch: " stream)

                   (princ sentence stream))

            do (html:new-paragraph :stream stream)))))





Rainer Joswig, Lavielle EDV Systemberatung GmbH & Co, Lotharstrasse 2b,
D22041

Hamburg, Tel: +49 40 658088, Fax: +49 40 65808-202,

Email: joswig@lavielle.com , WWW: http://www.lavielle.com/~joswig/