From: Timo Sirainen Date: Mon, 30 Oct 2017 14:00:13 +0000 (+0200) Subject: lib-http: If istream read fails, preserve the istream's full error message X-Git-Tag: 2.3.0.rc1~694 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a8454fe986d4a881d3612eebb39101be1d6db94;p=thirdparty%2Fdovecot%2Fcore.git lib-http: If istream read fails, preserve the istream's full error message --- diff --git a/src/lib-http/http-header-parser.c b/src/lib-http/http-header-parser.c index 76ede04f8f..97ac01485a 100644 --- a/src/lib-http/http-header-parser.c +++ b/src/lib-http/http-header-parser.c @@ -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; } diff --git a/src/lib-http/http-message-parser.c b/src/lib-http/http-message-parser.c index c789ac2d39..cfee8a9d0c 100644 --- a/src/lib-http/http-message-parser.c +++ b/src/lib-http/http-message-parser.c @@ -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; diff --git a/src/lib-http/http-response-parser.c b/src/lib-http/http-response-parser.c index 7edc876638..c24bfa3cee 100644 --- a/src/lib-http/http-response-parser.c +++ b/src/lib-http/http-response-parser.c @@ -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;