small enhancement to last fix, pointed out by Alex Cornejo

* nanohttp.c: small enhancement to last fix, pointed out
  by Alex Cornejo

svn path=/trunk/; revision=3617
diff --git a/ChangeLog b/ChangeLog
index 8a9e85e..4f8e95d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue May 15 22:18:08 PDT 2007 William Brack <wbrack@mmm.com.hk>
+
+	* nanohttp.c: small enhancement to last fix, pointed out
+	  by Alex Cornejo
+
 Tue May 15 12:38:38 PDT 2007 William Brack <wbrack@mmm.com.hk>
 
 	* nanohttp.c: fixed problem on gzip streams (bug #438045)
diff --git a/nanohttp.c b/nanohttp.c
index 51bb898..2406e7e 100644
--- a/nanohttp.c
+++ b/nanohttp.c
@@ -1203,8 +1203,10 @@
  
         ctxt->strm->next_out = dest;
         ctxt->strm->avail_out = len;
+	ctxt->strm->avail_in = ctxt->inptr - ctxt->inrptr;
 
-        while (ctxt->strm->avail_out > 0 && xmlNanoHTTPRecv(ctxt) > 0) {
+        while (ctxt->strm->avail_out > 0 &&
+	       (ctxt->strm->avail_in > 0 || xmlNanoHTTPRecv(ctxt) > 0)) {
             orig_avail_in = ctxt->strm->avail_in =
 			    ctxt->inptr - ctxt->inrptr - bytes_read;
             ctxt->strm->next_in = BAD_CAST (ctxt->inrptr + bytes_read);
@@ -1216,7 +1218,6 @@
 	}
 
         ctxt->inrptr += bytes_read;
-	ctxt->strm->avail_in = ctxt->inptr - ctxt->inrptr;
         return(len - ctxt->strm->avail_out);
     }
 #endif