guile-devel
[Top][All Lists]
Advanced

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

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


From: Nala Ginrut
Subject: Re: [FEATURE Request] Built-in server should support a thunk as body
Date: Tue, 26 Aug 2014 13:30:06 +0800

I attached the patch here.
The patch works for me. And I've tested it compared to the old way, say,
read the content to memory then pass it as the body then send to the
client.

Please test this feature with bigger file (larger than 20MB), the small
file is hard to show the difference.

On average, the old way is 5 times slower than new way (10s vs. 50s).

The test code is:
---------------------------code------------------------------
(define (send-the-file r fn)
 (define in (open-input-file fn))
 (define size (stat:size (stat fn)))
 (define res (build-response #:headers `((content-length . ,size))))
 (values res (lambda () (sendfile (request-port r) in size)
                        (close in))))

(run-server
 (lambda (r b)
  (send-the-file r "/var/www/mediawiki-1.21.3.tar.gz"))
 'http)
----------------------------end------------------------------

It's the users duty to pass all the related headers in this way.

The patch was attached.


Attachment: 0001-The-built-in-http-server-supports-thunk-as-body-to-t.patch
Description: Text Data


reply via email to

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