From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nala Ginrut Newsgroups: gmane.lisp.guile.devel Subject: [FEATURE Request] Built-in server should support a thunk as body Date: Mon, 25 Aug 2014 15:25:06 +0800 Organization: HFG Message-ID: <1408951506.3269.11.camel@Renee-desktop.suse> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1408951548 20974 80.91.229.3 (25 Aug 2014 07:25:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 Aug 2014 07:25:48 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Aug 25 09:25:42 2014 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XLoer-0006hf-La for guile-devel@m.gmane.org; Mon, 25 Aug 2014 09:25:41 +0200 Original-Received: from localhost ([::1]:46543 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLoer-0006es-6W for guile-devel@m.gmane.org; Mon, 25 Aug 2014 03:25:41 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50796) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLoeZ-0006bg-EW for guile-devel@gnu.org; Mon, 25 Aug 2014 03:25:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XLoeQ-0002Jp-AL for guile-devel@gnu.org; Mon, 25 Aug 2014 03:25:23 -0400 Original-Received: from mail-pd0-x22a.google.com ([2607:f8b0:400e:c02::22a]:33518) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLoeQ-0002Gv-3K for guile-devel@gnu.org; Mon, 25 Aug 2014 03:25:14 -0400 Original-Received: by mail-pd0-f170.google.com with SMTP id g10so19940261pdj.1 for ; Mon, 25 Aug 2014 00:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:date:organization:content-type :mime-version:content-transfer-encoding; bh=9bvp+JYO62BWG4EDYpnZ5cMMnf2/ANbsCryHCvuLZDE=; b=mbEmRmit+rlJ765m/FAHuC+gDSxXgtN8FNE5U/f8N4Qi1LCD/spTbtPmKsopg3roSD 9pgumPom6TIvRKN0Tspom+UgPJmE2Kz65fBLUOtsnS4HKoKs805zIP6/xykfFUlx3uT7 lzXxnIQy8riDyBffPrBtJxar9Tr1/zUEan5ntpSLiF1h9cRrVCKBLoIYg7mPvgO2Pf1t z6qnfpQ87nGhZzrofYVDmmmEGw9cweLjc3ieIup/Pq/JzgRDhwYcT4/9xooewPo9b0cq QDe2h9275VytyNuCU+4TjT9L1L77zQcxNXm+9Xvbqu7P3vz9ADqOSrmUZWBp9DopqNQ5 CNyg== X-Received: by 10.70.35.67 with SMTP id f3mr26042618pdj.34.1408951512264; Mon, 25 Aug 2014 00:25:12 -0700 (PDT) Original-Received: from [147.2.147.182] ([203.192.156.9]) by mx.google.com with ESMTPSA id zf5sm132802816pac.41.2014.08.25.00.25.08 for (version=SSLv3 cipher=RC4-SHA bits=128/128); Mon, 25 Aug 2014 00:25:11 -0700 (PDT) X-Mailer: Evolution 3.4.4 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c02::22a X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:17361 Archived-At: 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?