guile-devel
[Top][All Lists]
Advanced

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

[FEATURE Request] Built-in server should support a thunk as body


From: Nala Ginrut
Subject: [FEATURE Request] Built-in server should support a thunk as body
Date: Mon, 25 Aug 2014 15:25:06 +0800

I'm trying to handle static file with our sendfile, but I realized it's
impossible to call it in the handler of run-server.
Although sanitize-response supports procedure as body, it never let me
use sendfile at any chance, because the final writing operation should
be delayed to server-impl-write. If I do it in advanced (in
sanitize-response), the body will appear before the http header, which
is wrong way.

My suggestion is to support thunk as body, the thunk included body
writing operation, and sanitize-response will pass it to the next step
without any cooking. When server-impl-write detected it's a thunk, it'll
call it directly to write the body rather than calling
write-response-body.

Of course, in this way, users have to pass Content-Length manually in
build-response. Consider the size of file will be confirmed when calling
sendfile, it's easy to do that.

In short, my approach is some kind of lazy evaluation for body handling.

I can format a patch if it's agreed.

Comments?





reply via email to

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