summaryrefslogtreecommitdiff
path: root/src/pkg/http/chunked.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/http/chunked.go')
-rw-r--r--src/pkg/http/chunked.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/pkg/http/chunked.go b/src/pkg/http/chunked.go
index 59121c5a2..6c23e691f 100644
--- a/src/pkg/http/chunked.go
+++ b/src/pkg/http/chunked.go
@@ -9,6 +9,7 @@ import (
"log"
"os"
"strconv"
+ "bufio"
)
// NewChunkedWriter returns a new writer that translates writes into HTTP
@@ -64,3 +65,13 @@ func (cw *chunkedWriter) Close() os.Error {
_, err := io.WriteString(cw.Wire, "0\r\n")
return err
}
+
+// NewChunkedReader returns a new reader that translates the data read from r
+// out of HTTP "chunked" format before returning it.
+// The reader returns os.EOF when the final 0-length chunk is read.
+//
+// NewChunkedReader is not needed by normal applications. The http package
+// automatically decodes chunking when reading response bodies.
+func NewChunkedReader(r *bufio.Reader) io.Reader {
+ return &chunkedReader{r: r}
+}