]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client: Simplified return code handling in http_client_request_send_real().
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 17 Feb 2018 14:02:53 +0000 (15:02 +0100)
committerStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 17 Feb 2018 14:49:41 +0000 (15:49 +0100)
src/lib-http/http-client-request.c

index 06077ec10534a87991efd0afee5c551772a5a649..c3071db73d275fbdfc8571cac024d3e23cdd9ca1 100644 (file)
@@ -1151,7 +1151,6 @@ static int http_client_request_send_real(struct http_client_request *req,
        struct http_client_connection *conn = req->conn;
        string_t *rtext = t_str_new(256);
        struct const_iovec iov[3];
-       int ret = 0;
 
        i_assert(!req->conn->output_locked);
        i_assert(req->payload_output == NULL);
@@ -1264,32 +1263,31 @@ static int http_client_request_send_real(struct http_client_request *req,
        o_stream_cork(conn->conn.output);
        if (o_stream_sendv(conn->conn.output, iov, N_ELEMENTS(iov)) < 0) {
                http_client_connection_handle_output_error(conn);
-               ret = -1;
-       } else {
-               e_debug(req->event, "Sent header");
-
-               if (req->payload_output != NULL) {
-                       if (!req->payload_sync) {
-                               if (http_client_request_send_more(req, pipelined) < 0)
-                                       ret = -1;
-                       } else {
-                               e_debug(req->event, "Waiting for 100-continue");
-                               conn->output_locked = TRUE;
-                       }
+               return -1;
+       }
+
+       e_debug(req->event, "Sent header");
+
+       if (req->payload_output != NULL) {
+               if (!req->payload_sync) {
+                       if (http_client_request_send_more(req, pipelined) < 0)
+                               return -1;
                } else {
-                       req->state = HTTP_REQUEST_STATE_WAITING;
-                       if (!pipelined)
-                               http_client_connection_start_request_timeout(req->conn);
-                       conn->output_locked = FALSE;
+                       e_debug(req->event, "Waiting for 100-continue");
+                       conn->output_locked = TRUE;
                }
+       } else {
+               req->state = HTTP_REQUEST_STATE_WAITING;
+               if (!pipelined)
+                       http_client_connection_start_request_timeout(req->conn);
+               conn->output_locked = FALSE;
        }
-       if (ret >= 0 && conn->conn.output != NULL &&
+       if (conn->conn.output != NULL &&
            o_stream_uncork_flush(conn->conn.output) < 0) {
                http_client_connection_handle_output_error(conn);
-               ret = -1;
+               return -1;
        }
-
-       return ret;
+       return 0;
 }
 
 int http_client_request_send(struct http_client_request *req,