From: Stephan Bosch Date: Sat, 29 Aug 2015 11:20:57 +0000 (+0300) Subject: lib-http: client: Added proper handling of 408 response status. X-Git-Tag: 2.2.19.rc1~161 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=62812c68a2086b900466efbbbdd49b1cdb7a38b3;p=thirdparty%2Fdovecot%2Fcore.git lib-http: client: Added proper handling of 408 response status. This is treated as a special server connection close event, rather than a response to the last issued request. --- diff --git a/src/lib-http/http-client-connection.c b/src/lib-http/http-client-connection.c index fffac111d1..1a7286fe63 100644 --- a/src/lib-http/http-client-connection.c +++ b/src/lib-http/http-client-connection.c @@ -657,7 +657,15 @@ static void http_client_connection_input(struct connection *_conn) if (req == NULL) { /* server sent response without any requests in the wait list */ - http_client_connection_debug(conn, "Got unexpected input from server"); + if (response.status == 408) { + http_client_connection_debug(conn, + "Server explicitly closed connection: 408 %s", + response.reason); + } else { + http_client_connection_debug(conn, + "Got unexpected input from server: %u %s", + response.status, response.reason); + } http_client_connection_close(&conn); return; } @@ -780,6 +788,14 @@ static void http_client_connection_input(struct connection *_conn) http_client_request_delay_from_response(req, &response) > 0 && http_client_request_try_retry(req)) handled = TRUE; + /* request timeout (by server) */ + } else if (response.status == 408) { + /* automatically retry */ + if (http_client_request_try_retry(req)) + handled = TRUE; + /* connection close is implicit, although server should indicate + that explicitly */ + conn->close_indicated = TRUE; } }