chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] http server example question


From: Peter Bex
Subject: Re: [Chicken-users] http server example question
Date: Thu, 28 Feb 2008 10:22:05 +0100
User-agent: Mutt/1.4.2.3i

On Thu, Feb 28, 2008 at 09:55:01AM +0100, minh thu wrote:
> Hi
> 
> I'm trying to use spiffy. I've a little problem which is in fact
> related to the 'http' egg.
> 
> Using the 'server example' from the 'http' wiki page with firefox,
> firefox try to load the page for ever; it's only when I kill the
> server (closing the port) that the page appears in firefox.
> 
> How should I handle this ? Is the Content-Length header field
> important for this ?

The example is incorrect.  The write-response-header accepts the
request, the status code, the status message and the alist of headers.
The status code and message were left out.  Sorry about that, I've
fixed it on the wiki.

The correct example is:
(require-extension http-server)

(http:add-resource '("/" "/index.html")
  (lambda (r a)
    (let ([msg "<h1>Hello, world!</h1>"])
      (http:write-response-header 
        r
        200
        "OK"
        `(("Content-type" . "test/html")
          ("Content-length" . ,(string-length msg))))
      (display msg) ) ) )

((http:make-server 4242) #t)

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
                                                        -- Donald Knuth

Attachment: pgpsQWlQKOqWi.pgp
Description: PGP signature


reply via email to

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