[gambit-list] web server example

Fred Weigel fred_weigel at hotmail.com
Tue Jan 22 12:45:39 EST 2013


Marc

Thanks for the fix! I didn't actually replace (print) with (display). My
hack was:

(begin
;; the (print) isn't -- don't know what the issue is, but it
;; sure doesn't work the way we want -- but then using (display)
;; does work.
(display version port) (display " 200 OK" port) (display eol port)
(display "Content-Length: " port)
  (display (u8vector-length message) port) (display eol port)
(display "Content-Type: text/html; charset=ISO-8859-1" port)
  (display eol port)
(display "Connection: close" port) (display eol port)
(display eol port)
)

I'll implement your fix, instead of my hack (it sure is cleaner). Thanks
again!

Offtopic - you had mentioned future support of native threading. I have
been using the Unix fork() primitive to use multi-core. This forces IPC
using messages (or sockets). As part of this, I started playing around
with Unix shm (shared memory). The problem is that I really couldn't
get more performance, because data needs to be copied to the shared
memory. It struck me that to get the performance I was after the
copy would have to be removed. In other words, (shared) Scheme objects
would have to reside *in* the shared memory region.

Just wondering what direction you are contemplating with Gambit-C
(or am I completely off-base)?

FredW

On Tue, 2013-01-22 at 11:42 -0500, Marc Feeley wrote: 
> On 2013-01-22, at 11:14 AM, Fred Weigel <fred_weigel at hotmail.com> wrote:
> 
> > A sample web server is supplied with Gambit-C. I am using gsi 4.6.6
> > 
> > [fred at dejah Gambit-C]$ gsi
> > Gambit v4.6.6
> > 
> >> 
> > 
> > and tried the web server (for inclusion into some of my own code). I do
> > like the design, but there seems to be a bug. In http.scm line 827,
> > there is a reference to function (print). The problem is that (print)
> > doesn't produce ANY output on "port", and the contents are then
> > interpreted as a flat text file. I replaced (print) with (display), and
> > the thing works (as expected).
> > 
> > Running on Fedora 17 Linux, with the invocation
> > 
> > gsi base64 html http web-server 8000
> > 
> > (as recommended).
> 
> Strange that this incorrect call to print went unnoticed for so long...  You can't simply replace the call to print by a call to display.  The correct fix is:
> 
>                 (print
>                  port: port
>                  (list version " 200 OK" eol
>                        "Content-Length: " (u8vector-length message) eol
>                        "Content-Type: text/html; charset=ISO-8859-1" eol
>                        "Connection: close" eol
>                        eol))
> 
> Thanks for reporting the problem!
> 
> Marc
> 
> 




More information about the Gambit-list mailing list