Subject: | PoCoCl::HTTP in some cases return double responses. |
Some time ago I was saying that in some cases Cl::HTTP sends double
responses (postbacks) to requesting session.
Now I found this situation. That happens if remote host send RST TCP
packet instead of FIN when closing connection (this behavior occur that
socket has SO_LINGER turned on and linger time is 0).
In this situation client receives correct response (because
content-length bytes read successfully) and after it receives 400
response with error "read error 104: Connection reset by peer".
I created a patch to fix this situation.
Index: HTTP.pm
===================================================================
--- HTTP.pm (revision 217)
+++ HTTP.pm (working copy)
@@ -358,7 +358,9 @@
# If there was a non-zero error, then something bad happened. Post
# an error response back.
if ($errnum) {
- $request->error(400, "$operation error $errnum: $errstr");
+ unless ($request->[REQ_STATE] & RS_POSTED) {
+ $request->error(400, "$operation error $errnum: $errstr");
+ }
return;
}