From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.user Subject: Re: Streaming responses with Guile's web modules Date: Sun, 23 Sep 2018 15:20:08 +0200 Message-ID: <87h8igtkon.fsf@gnu.org> References: <87in32y4m0.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1537708730 29195 195.159.176.226 (23 Sep 2018 13:18:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 23 Sep 2018 13:18:50 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Sep 23 15:18:46 2018 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g44Hd-0007Ue-BX for guile-user@m.gmane.org; Sun, 23 Sep 2018 15:18:45 +0200 Original-Received: from localhost ([::1]:40592 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g44Jj-0001GC-BY for guile-user@m.gmane.org; Sun, 23 Sep 2018 09:20:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45776) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g44JG-0001Dv-V0 for guile-user@gnu.org; Sun, 23 Sep 2018 09:20:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g44JB-00076u-JN for guile-user@gnu.org; Sun, 23 Sep 2018 09:20:25 -0400 Original-Received: from [195.159.176.226] (port=35810 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g44JB-00075L-7z for guile-user@gnu.org; Sun, 23 Sep 2018 09:20:21 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1g44Gx-0006nj-Qc for guile-user@gnu.org; Sun, 23 Sep 2018 15:18:03 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 34 Original-X-Complaints-To: usenet@blaine.gmane.org X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 2 =?utf-8?Q?Vend=C3=A9miaire?= an 227 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Cancel-Lock: sha1:aLDBh8dUEzs3RKFD627cF+9UXss= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:14899 Archived-At: Hi Roel, Roel Janssen skribis: > I'd like to implement a web server using the (web server) module, but > allow for “streaming” results. The way I image this would look like, > is something like this: > > (define (request-handler request body) > (values '((content-type . (text/plain))) > ;; This function can build its response by writing to > ;; ‘port’, rather than to return the whole body as a > ;; string. > (lambda (port) > (format port "Hello world!")))) > > (run-server request-handler) > > Is this possible with the (web server) module? If so, how? > If not, what would be a good starting point to implement this? As discussed on IRC a few days ago, this is not really possible. ‘guix publish’ works around it by providing a custom implementation of the ‘write’ method of the HTTP server and having handlers provide a “fake” body to be interpreted by this ‘write’ implementation: https://git.savannah.gnu.org/cgit/guix.git/tree/guix/scripts/publish.scm#n690 https://git.savannah.gnu.org/cgit/guix.git/tree/guix/scripts/publish.scm#n522 I reported this limitation of (web server) at . Thanks, Ludo’.