]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client: Added proper handling of 408 response status.
authorStephan Bosch <stephan@rename-it.nl>
Sat, 29 Aug 2015 11:20:57 +0000 (14:20 +0300)
committerStephan Bosch <stephan@rename-it.nl>
Sat, 29 Aug 2015 11:20:57 +0000 (14:20 +0300)
This is treated as a special server connection close event, rather than a
response to the last issued request.

src/lib-http/http-client-connection.c

index fffac111d1ae79759d72b25080a2459c208a28d0..1a7286fe63d79ff342a4fb70a7e618011095f458 100644 (file)
@@ -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;
                                }
                        }