dovecot-2.2: lib-http: Minor fix/cleanup to detecting stream err...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jul 11 10:20:02 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/dbda2f84aeaa
changeset: 16601:dbda2f84aeaa
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jul 11 10:19:43 2013 +0300
description:
lib-http: Minor fix/cleanup to detecting stream errors when skipping payload.

diffstat:

 src/lib-http/http-response-parser.c |  22 ++++++++--------------
 1 files changed, 8 insertions(+), 14 deletions(-)

diffs (37 lines):

diff -r 1ab7d7dd3087 -r dbda2f84aeaa src/lib-http/http-response-parser.c
--- 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


More information about the dovecot-cvs mailing list