Index: PostInputStream.java
===================================================================
RCS file: /home/cvspublic/xml-cocoon2/src/org/apache/cocoon/util/PostInputStream.java,v
retrieving revision 1.5
diff -u -r1.5 PostInputStream.java
--- PostInputStream.java	2001/10/11 07:28:25	1.5
+++ PostInputStream.java	2001/10/22 03:10:05
@@ -151,7 +151,8 @@
         if (m_bytesRead == m_contentLen) {
             return -1;
         }
-        int num = m_inputStream.read(buffer, offset, len);
+        int available = Math.min( available(), len );
+		int num = m_inputStream.read( buffer, offset, available );
         if (num > 0) {
             m_bytesRead += num;
         }
@@ -185,8 +186,16 @@
      * @exception  IOException  if an I/O error occurs.
      */
     public synchronized long skip(long n) throws IOException {
-        checkOpen();
-        return m_inputStream.skip(n);
+		checkOpen();
+		if ( m_bytesRead == m_contentLen )
+		{
+			return ( 0 );
+		}
+		else
+		{
+			return ( m_inputStream.skip( n ) );
+		}
+
     }
 
     /**

