Make the web server buffer size configurable

This commit is contained in:
Christopher Baines 2025-01-29 16:17:56 +00:00
parent c90cc88da7
commit b5cc5fd077

View file

@ -299,11 +299,12 @@ on the procedure being called at any particular time."
(define* (client-loop client handler (define* (client-loop client handler
exception-handler exception-handler
write-response-exception-handler write-response-exception-handler
connection-idle-timeout) connection-idle-timeout
buffer-size)
;; Always disable Nagle's algorithm, as we handle buffering ;; Always disable Nagle's algorithm, as we handle buffering
;; ourselves; when we force-output, we really want the data to go ;; ourselves; when we force-output, we really want the data to go
;; out. ;; out.
(setvbuf client 'block 1024) (setvbuf client 'block buffer-size)
(setsockopt client IPPROTO_TCP TCP_NODELAY 1) (setsockopt client IPPROTO_TCP TCP_NODELAY 1)
(with-throw-handler #t (with-throw-handler #t
(lambda () (lambda ()
@ -352,7 +353,8 @@ on the procedure being called at any particular time."
default-exception-handler) default-exception-handler)
(write-response-exception-handler (write-response-exception-handler
default-write-response-exception-handler) default-write-response-exception-handler)
(connection-idle-timeout 60)) (connection-idle-timeout 60)
(connection-buffer-size 1024))
"Run the knots web server. "Run the knots web server.
HANDLER should be a procedure that takes one argument, the HTTP HANDLER should be a procedure that takes one argument, the HTTP
@ -387,7 +389,8 @@ before sending back to the client."
(client-loop client handler (client-loop client handler
exception-handler exception-handler
write-response-exception-handler write-response-exception-handler
connection-idle-timeout)) connection-idle-timeout
connection-buffer-size))
#:parallel? #t) #:parallel? #t)
(loop)))))) (loop))))))