changeset 5660:6533e11eda80 HEAD

If there's no message body, the final read() should return -1, not -2
author Timo Sirainen <tss@iki.fi>
date Thu, 24 May 2007 11:34:47 +0300
parents b118198fbfa3
children f18a7fd8ac9a
files src/lib-mail/istream-header-filter.c
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-mail/istream-header-filter.c	Wed May 23 23:15:17 2007 +0300
+++ b/src/lib-mail/istream-header-filter.c	Thu May 24 11:34:47 2007 +0300
@@ -72,6 +72,16 @@
 	    mstream->istream.istream.v_offset +
 	    (mstream->istream.pos - mstream->istream.skip) ==
 	    mstream->header_size.virtual_size) {
+		/* if there's no body at all, return EOF */
+		(void)i_stream_get_data(mstream->input, &pos);
+		if (pos == 0) {
+			ret = i_stream_read(mstream->input);
+			if (ret == -1) {
+				/* EOF */
+				mstream->istream.istream.eof = TRUE;
+				return -1;
+			}
+		}
 		/* we don't support mixing headers and body.
 		   it shouldn't be needed. */
 		return -2;
@@ -182,11 +192,13 @@
 	}
 
 	if (ret == 0) {
+		/* we're at the end of headers. */
 		i_assert(hdr == NULL);
 		i_assert(mstream->istream.istream.v_offset +
 			 mstream->istream.pos ==
 			 mstream->header_size.virtual_size);
-		return -2;
+
+		return read_header(mstream);
 	}
 
 	return ret;