Mathieu Othacehe writes: >> + (match (assq 'connection (response-headers response)) >> + (('connection 'close) >> + (lambda () >> + (close-port port))) > > You could maybe factorize it in a close-connection? procedure. Out of > curiosity, when does the remote server asks for connection closing? A server can at any time ask for the connection to be closed. With NGinx for example, by default, it'll close connections after 1000 requests: http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive_requests