Email list hosting service & mailing list manager

HTTP request handler / middleware SRFI Lassi Kortela (05 Apr 2019 11:34 UTC)
Re: HTTP request handler / middleware SRFI Shiro Kawai (05 Apr 2019 12:05 UTC)
Re: HTTP request handler / middleware SRFI Lassi Kortela (05 Apr 2019 12:24 UTC)
Re: HTTP request handler / middleware SRFI Shiro Kawai (05 Apr 2019 17:45 UTC)
Re: HTTP request handler / middleware SRFI Peter Bex (05 Apr 2019 14:02 UTC)
Re: HTTP request handler / middleware SRFI Lassi Kortela (05 Apr 2019 15:50 UTC)
Re: HTTP request handler / middleware SRFI Peter Bex (05 Apr 2019 15:58 UTC)
Re: HTTP request handler / middleware SRFI Lassi Kortela (05 Apr 2019 16:19 UTC)
Re: HTTP request handler / middleware SRFI Peter (05 Apr 2019 16:47 UTC)
Re: HTTP request handler / middleware SRFI Peter Bex (05 Apr 2019 20:14 UTC)
Re: HTTP request handler / middleware SRFI Lassi Kortela (05 Apr 2019 21:51 UTC)
Re: HTTP request handler / middleware SRFI Shiro Kawai (05 Apr 2019 19:02 UTC)
Re: HTTP request handler / middleware SRFI Lassi Kortela (05 Apr 2019 13:11 UTC)
Re: HTTP request handler / middleware SRFI Peter (05 Apr 2019 13:20 UTC)
Re: HTTP request handler / middleware SRFI Lassi Kortela (05 Apr 2019 13:38 UTC)
Re: HTTP request handler / middleware SRFI Peter (05 Apr 2019 13:58 UTC)
Re: HTTP request handler / middleware SRFI Lassi Kortela (05 Apr 2019 15:18 UTC)
Re: HTTP request handler / middleware SRFI Arthur A. Gleckler (05 Apr 2019 21:19 UTC)
Re: HTTP request handler / middleware SRFI Lassi Kortela (06 Apr 2019 00:08 UTC)
(missing)
Re: HTTP request handler / middleware SRFI Arthur A. Gleckler (06 Apr 2019 05:31 UTC)
Re: HTTP request handler / middleware SRFI Peter (06 Apr 2019 07:30 UTC)
Re: HTTP request handler / middleware SRFI Arthur A. Gleckler (06 Apr 2019 20:20 UTC)
Re: HTTP request handler / middleware SRFI John Cowan (06 Apr 2019 23:10 UTC)
Re: HTTP request handler / middleware SRFI Duy Nguyen (10 Sep 2019 14:12 UTC)
Re: HTTP request handler / middleware SRFI Arthur A. Gleckler (10 Sep 2019 14:18 UTC)
Re: HTTP request handler / middleware SRFI Peter Bex (06 Apr 2019 08:24 UTC)

Re: HTTP request handler / middleware SRFI Lassi Kortela 05 Apr 2019 13:37 UTC

> I have a working SCGI implementation for both MIT and chez scheme
> (ported, not the same codebase, but only superficial differences).
>
> It is rather ugly code, but I've used it in production with both nginx
> and apache, and it seems to work fine. It is written purely in Scheme.

Great! Have you considered publishing the Chez version in Akku?
<https://akkuscm.org/>

> Headers are passed as alists, bodies as bytevectors / strings. This is
> not ideal, sometimes it would be better to be able to write content
> directly, but I haven't figured out how to properly do this *and*
> support custom headers nicely.

Do you mean that if the user's handler returns an alist of response
headers, then you need to ensure that it didn't write anything in the
body before the server gets the chance to write those headers?

Off the top of my head, here's a sketch:

     (define (handler1 req)
       "Hello world")

     (define (handler2 req)
       '(200
         ((content-type "text/plain"))
         "Hello world"))

     (define (handler3 req)
       (append-header! req 'content-type "text/plain")
       (flush-header req)
       (append-to-body! req "Hello ")
       (append-to-body! req "world")
       #f)

So append-to-body! would cause an error unless flush-header has been
called on that request.

In addition, flush-header would be implicitly called after writing all
the headers from the handler's return value and before writing the body
from the return value.

> Also, there is no portable way to have
> custom ports in Scheme, so that makes things even harder :-/

Yeah, I ran into that issue with the archive file SRFI as well. I made
it so you can either pass a filename, a byte port, or an arbitrary
procedure that has an interface similar to read-bytevector! or
write-bytevector.

> I'd strongly suggest implementing this and getting it stable before
> writing an actual SRFI for it.

That is the plan :) But we'd need to get some momentum going and do it
with a view to eventually publishing an SRFI, hence have a draft spec
from the get go so we remember not to bake in assumptions about the
particular implementation strategies we happen to be using.