Browse Source

Merge pull request #6320 from LK4D4/fix_stdcopy_eof

Don't exit on eof in header reading in stdcopy
Michael Crosby 11 years ago
parent
commit
4dcf4e9bd0
1 changed files with 5 additions and 4 deletions
  1. 5 4
      utils/stdcopy.go

+ 5 - 4
utils/stdcopy.go

@@ -82,13 +82,14 @@ func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error)
 		for nr < StdWriterPrefixLen {
 			var nr2 int
 			nr2, er = src.Read(buf[nr:])
-			if er == io.EOF {
-				return written, nil
-			}
-			if er != nil {
+			// Don't exit on EOF, because we can have some more input
+			if er != nil && er != io.EOF {
 				return 0, er
 			}
 			nr += nr2
+			if nr == 0 {
+				return written, nil
+			}
 		}
 
 		// Check the first byte to know where to write