unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [FEATURE Request] Built-in server should support a thunk as body
@ 2014-08-25  7:25 Nala Ginrut
  2014-08-25 12:16 ` David Thompson
  0 siblings, 1 reply; 5+ messages in thread
From: Nala Ginrut @ 2014-08-25  7:25 UTC (permalink / raw)
  To: guile-devel

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?





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-08-26  6:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-25  7:25 [FEATURE Request] Built-in server should support a thunk as body Nala Ginrut
2014-08-25 12:16 ` David Thompson
2014-08-25 14:52   ` Nala Ginrut
2014-08-26  5:30   ` Nala Ginrut
2014-08-26  6:38     ` Nala Ginrut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).