]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: Use [io]_stream_get_error() instead of just errno strings.
authorTimo Sirainen <tss@iki.fi>
Wed, 6 Nov 2013 17:03:10 +0000 (19:03 +0200)
committerTimo Sirainen <tss@iki.fi>
Wed, 6 Nov 2013 17:03:10 +0000 (19:03 +0200)
src/lib-http/http-client-connection.c
src/lib-http/http-client-request.c
src/lib-http/test-http-client.c

index ce151452e279f715a46cbb17276f62b6f66af055..c1d03cc8465edef054f883a6758bddc56c4434a8 100644 (file)
@@ -361,7 +361,7 @@ static void http_client_connection_destroy(struct connection *_conn)
                /* retry pending requests if possible */
                error = _conn->input == NULL ? "Connection lost" :
                        t_strdup_printf("Connection lost: %s",
-                                       strerror(_conn->input->stream_errno));
+                                       i_stream_get_error(_conn->input));
                http_client_connection_debug(conn, "%s", error);
                http_client_connection_retry_requests(conn,
                        HTTP_CLIENT_REQUEST_ERROR_CONNECTION_LOST, error);
@@ -646,7 +646,8 @@ static void http_client_connection_input(struct connection *_conn)
                        t_strdup_printf("Connection lost: read(%s) failed: %s",
                                        i_stream_get_name(conn->conn.input),
                                        stream_errno != 0 ?
-                                       strerror(stream_errno) : "EOF"));
+                                       i_stream_get_error(conn->conn.input) :
+                                       "EOF"));
                return;
        }
 
@@ -681,8 +682,9 @@ int http_client_connection_output(struct http_client_connection *conn)
                if (ret < 0) {
                        http_client_connection_abort_temp_error(&conn,
                                HTTP_CLIENT_REQUEST_ERROR_CONNECTION_LOST,
-                               t_strdup_printf("Connection lost: write(%s) failed: %m",
-                                               o_stream_get_name(output)));
+                               t_strdup_printf("Connection lost: write(%s) failed: %s",
+                                               o_stream_get_name(output),
+                                               o_stream_get_error(output)));
                }
                return ret;
        }
index 8ca4b8153788377a09fd7375dbd1b5bb2aadf080..64f8c2fc1b2a7d78bd62ab09b0eaca610421d80c 100644 (file)
@@ -256,8 +256,9 @@ void http_client_request_set_payload(struct http_client_request *req,
        req->payload_input = input;
        if ((ret = i_stream_get_size(input, TRUE, &req->payload_size)) <= 0) {
                if (ret < 0) {
-                       i_error("i_stream_get_size(%s) failed: %m",
-                               i_stream_get_name(input));
+                       i_error("i_stream_get_size(%s) failed: %s",
+                               i_stream_get_name(input),
+                               i_stream_get_error(input));
                }
                req->payload_size = 0;
                req->payload_chunked = TRUE;
@@ -505,14 +506,16 @@ int http_client_request_send_more(struct http_client_request *req,
                /* we're in the middle of sending a request, so the connection
                   will also have to be aborted */
                errno = req->payload_input->stream_errno;
-               *error_r = t_strdup_printf("read(%s) failed: %m",
-                                          i_stream_get_name(req->payload_input));
+               *error_r = t_strdup_printf("read(%s) failed: %s",
+                                          i_stream_get_name(req->payload_input),
+                                          i_stream_get_error(req->payload_input));
                ret = -1;
        } else if (output->stream_errno != 0) {
                /* failed to send request */
                errno = output->stream_errno;
-               *error_r = t_strdup_printf("write(%s) failed: %m",
-                                          o_stream_get_name(output));
+               *error_r = t_strdup_printf("write(%s) failed: %s",
+                                          o_stream_get_name(output),
+                                          o_stream_get_error(output));
                ret = -1;
        } else {
                i_assert(ret >= 0);
@@ -631,8 +634,9 @@ static int http_client_request_send_real(struct http_client_request *req,
        req->state = HTTP_REQUEST_STATE_PAYLOAD_OUT;
        o_stream_cork(output);
        if (o_stream_sendv(output, iov, N_ELEMENTS(iov)) < 0) {
-               *error_r = t_strdup_printf("write(%s) failed: %m",
-                                          o_stream_get_name(output));
+               *error_r = t_strdup_printf("write(%s) failed: %s",
+                                          o_stream_get_name(output),
+                                          o_stream_get_error(output));
                ret = -1;
        }
 
index 83b09a17596990678e77e64b5b21a851c6f1ac1b..9d2a405dbe6a9370985b0df0458d8072e83e02b8 100644 (file)
@@ -31,9 +31,10 @@ static void payload_input(struct http_test_request *req)
                i_info("DEBUG: REQUEST: NEED MORE DATA");
                /* we will be called again for this request */
        } else {
-               if (req->payload->stream_errno != 0)
-                       i_error("REQUEST PAYLOAD READ ERROR: %m");
-               else
+               if (req->payload->stream_errno != 0) {
+                       i_error("REQUEST PAYLOAD READ ERROR: %s",
+                               i_stream_get_error(req->payload));
+               } else
                        i_info("DEBUG: REQUEST: Finished");
                io_remove(&req->io);
                i_stream_unref(&req->payload);