]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: If istream read fails, preserve the istream's full error message
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 30 Oct 2017 14:00:13 +0000 (16:00 +0200)
committerTimo Sirainen <tss@dovecot.fi>
Mon, 30 Oct 2017 15:10:30 +0000 (17:10 +0200)
src/lib-http/http-header-parser.c
src/lib-http/http-message-parser.c
src/lib-http/http-response-parser.c

index 76ede04f8fa799854be9283a28507a684098d1c4..97ac01485acd818ae9ccde6c5126a93e3bce4b22 100644 (file)
@@ -360,7 +360,8 @@ int http_header_parse_next_field(struct http_header_parser *parser,
                if (parser->input->stream_errno == 0)
                        *error_r = "Premature end of input";
                else
-                       *error_r = "Stream error";
+                       *error_r = t_strdup_printf("Stream error: %s",
+                               i_stream_get_error(parser->input));
        }
        return ret;
 }
index c789ac2d3918ada01940a1fb8e7f574657a09f15..cfee8a9d0c796fba0144bbe60d8680a19ff6213c 100644 (file)
@@ -119,7 +119,8 @@ int http_message_parse_finish_payload(struct http_message_parser *parser)
                                parser->error = "Invalid payload";
                        } else {
                                parser->error_code = HTTP_MESSAGE_PARSE_ERROR_BROKEN_STREAM;
-                               parser->error = "Stream error while skipping payload";
+                               parser->error = t_strdup_printf("Stream error while skipping payload: %s",
+                                                               i_stream_get_error(parser->payload));
                        }
                }
                return ret;
index 7edc87663885a0dc981da33dbe1df5d2da0fce36..c24bfa3cee988e8bd4273f4bde67e500098a3155 100644 (file)
@@ -264,7 +264,8 @@ http_response_parse_status_line(struct http_response_parser *parser)
                if (_parser->input->eof &&
                    parser->state == HTTP_RESPONSE_PARSE_STATE_INIT)
                        return 0;
-               _parser->error = "Stream error";
+               _parser->error = t_strdup_printf("Stream error: %s",
+                       i_stream_get_error(_parser->input));
                return -1;
        }
        return 0;