diff options
author | Ondřej Surý <ondrej@sury.org> | 2011-08-03 16:54:30 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2011-08-03 16:54:30 +0200 |
commit | 28592ee1ea1f5cdffcf85472f9de0285d928cf12 (patch) | |
tree | 32944e18b23f7fe4a0818a694aa2a6dfb1835463 /src/pkg/http/chunked.go | |
parent | e836bee4716dc0d4d913537ad3ad1925a7ac32d0 (diff) | |
download | golang-upstream/59.tar.gz |
Imported Upstream version 59upstream/59
Diffstat (limited to 'src/pkg/http/chunked.go')
-rw-r--r-- | src/pkg/http/chunked.go | 11 |
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} +} |