Navigation Menu

Skip to content

Commit

Permalink
bug20222: fix DO-HTTP-REQUEST returning connections
Browse files Browse the repository at this point in the history
It should not return the connection if it already knows it's not
keep-alive.

Change-Id: I865c0002170db2a9c677279d68ccb4de1d53302b
  • Loading branch information
Gabor authored and melisgl committed Jun 9, 2011
1 parent ab02222 commit 268f67b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 34 deletions.
1 change: 1 addition & 0 deletions client.cl
Expand Up @@ -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)

Expand Down
66 changes: 32 additions & 34 deletions test/t-aserve.cl
Expand Up @@ -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)))))))))))



Expand Down

0 comments on commit 268f67b

Please sign in to comment.