From 268f67b072126c27ffd8c00d420f0e81cebb1f68 Mon Sep 17 00:00:00 2001 From: Gabor Date: Thu, 26 May 2011 18:09:26 +0200 Subject: [PATCH] bug20222: fix DO-HTTP-REQUEST returning connections It should not return the connection if it already knows it's not keep-alive. Change-Id: I865c0002170db2a9c677279d68ccb4de1d53302b --- client.cl | 1 + test/t-aserve.cl | 66 +++++++++++++++++++++++------------------------- 2 files changed, 33 insertions(+), 34 deletions(-) diff --git a/client.cl b/client.cl index 9353e323..506ea38a 100644 --- a/client.cl +++ b/client.cl @@ -1119,6 +1119,7 @@ or \"foo.com:8000\", not ~s" proxy)) creq :connection))) then ; connection will close, let it indicate eof (setf (client-request-bytes-left creq) :unknown) + (setf (client-request-return-connection creq) nil) else ; no data in the response nil) diff --git a/test/t-aserve.cl b/test/t-aserve.cl index 6f8c6850..484e7868 100644 --- a/test/t-aserve.cl +++ b/test/t-aserve.cl @@ -1403,42 +1403,40 @@ :keep-alive t) (declare (ignore body headers uri)) (test 200 code2) - (test t (and "with no-keepalive" (not (null socket)))) - ; now reuse it + (if* (not (asc x-proxy)) + then (test t (not (null socket)) :fail-info "socket not kept alive")) - ;; bug20222: give a chance for the server to close the - ;; connection - (sleep (random 1.0)) - (multiple-value-bind (body code3 headers uri socket2) - (x-do-http-request (format nil "~a/redir-target" prefix-local) - :keep-alive t - :connection socket) - (declare (ignore body headers uri)) - (test 200 code3) - (if* (and (not (asc x-proxy)) - (not (asc x-ssl))) - then ; reuse should happen - (test socket (and "reuse socket" socket2)) - (asc-format "~%~%pause ~d seconds ....~%" - (+ net.aserve::*read-request-timeout* 10)) - (force-output) - (sleep (+ net.aserve::*read-request-timeout* 10)) - - ; now the server should have shut down the - ; socket so reuse will not happen - (multiple-value-bind (body code4 headers uri socket3) - (x-do-http-request (format nil "~a/redir-target" prefix-local) - :connection socket2) - (declare (ignore body headers uri)) - (test 200 code4) - (test t (and "not reuse socket" (not (eq socket2 socket3)))) - - - )))) - - - )) + (if* socket + then ;; now reuse it + ;; bug20222: give a chance for the server to close the + ;; connection + (sleep (random 1.0)) + (multiple-value-bind (body code3 headers uri socket2) + (x-do-http-request (format nil "~a/redir-target" prefix-local) + :keep-alive t + :connection socket) + (declare (ignore body headers uri)) + (test 200 code3) + (if* (and (not (asc x-proxy)) + (not (asc x-ssl))) + then ; reuse should happen + (test socket (and "reuse socket" socket2)) + (asc-format "~%~%pause ~d seconds ....~%" + (+ net.aserve::*read-request-timeout* 10)) + (force-output) + (sleep (+ net.aserve::*read-request-timeout* 10)) + ; now the server should have + ; shut down the socket so + ; reuse will not happen + (multiple-value-bind (body code4 headers uri socket3) + (x-do-http-request (format nil "~a/redir-target" + prefix-local) + :connection socket2) + (declare (ignore body headers uri)) + (test 200 code4) + (test t (and "not reuse socket" + (not (eq socket2 socket3)))))))))))