Mercurial > dovecot > core-2.2
changeset 16601:dbda2f84aeaa
lib-http: Minor fix/cleanup to detecting stream errors when skipping payload.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 11 Jul 2013 10:19:43 +0300 |
parents | 1ab7d7dd3087 |
children | 69cc86583da2 |
files | src/lib-http/http-response-parser.c |
diffstat | 1 files changed, 8 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-http/http-response-parser.c Thu Jul 11 10:17:49 2013 +0300 +++ b/src/lib-http/http-response-parser.c Thu Jul 11 10:19:43 2013 +0300 @@ -343,25 +343,19 @@ before we continue. */ if (parser->payload != NULL) { struct istream *payload = parser->payload; + const unsigned char *data; + size_t size; i_assert(parser->state == HTTP_RESPONSE_PARSE_STATE_INIT); - if (i_stream_have_bytes_left(payload)) { - do { - i_stream_skip(payload, i_stream_get_data_size(payload)); - } while ((ret=i_stream_read(payload)) > 0); - if (ret == 0) - return 0; - if (ret < 0 && !payload->eof) { + while ((ret = i_stream_read_data(payload, &data, &size, 0)) > 0) + i_stream_skip(payload, size); + if (ret == 0 || payload->stream_errno != 0) { + if (ret < 0) *error_r = "Stream error while skipping payload"; - return -1; - } + return ret; } - - if (payload->eof) { - i_stream_unref(&parser->payload); - parser->payload = NULL; - } + i_stream_unref(&parser->payload); } /* HTTP-message = start-line