[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] with-input-from-request does not close SSL socket
From: |
obscuroloconato |
Subject: |
Re: [Chicken-users] with-input-from-request does not close SSL socket |
Date: |
Wed, 14 Dec 2011 20:15:30 +0100 |
2011/12/14 Peter Bex <address@hidden>:
>
> Hm, that ought to work. Perhaps there's a bug in the openssl egg.
Yes it is a openssl problem.
I was able to solve the problem by replacing http-client with the
following code:
(define (https-1.0-post host path query thunk)
(let-values (((input output) (ssl-connect host 443)))
(handle-exceptions exn
(begin
(close-input-port input)
(close-output-port output)
(abort exn))
(let ((body (form-urlencode query separator: "&")))
(write-request
(make-request
major: 1 minor: 0
uri: (uri-reference path)
port: output
method: 'POST
headers: (headers
`((host (,host . #f))
(connection close)
(content-type application/x-www-form-urlencoded)
(content-length ,(string-length body))))))
(display body output)
(flush-output output)
(let ((result (thunk (read-response input))))
(close-input-port input)
(close-output-port output)
result)))))
Without explicitly closing the two ports, I got the same socket leaking.