Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
7983ab9d
Commit
7983ab9d
authored
Jun 29, 2011
by
Andrew Balholm
Committed by
Brad Fitzpatrick
Jun 29, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: make NewChunkedReader public
R=golang-dev, bradfitz CC=golang-dev
https://golang.org/cl/4634112
parent
45f956ab
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
5 deletions
+12
-5
chunked.go
src/pkg/http/chunked.go
+11
-0
request.go
src/pkg/http/request.go
+0
-4
transfer.go
src/pkg/http/transfer.go
+1
-1
No files found.
src/pkg/http/chunked.go
View file @
7983ab9d
...
...
@@ -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
}
}
src/pkg/http/request.go
View file @
7983ab9d
...
...
@@ -428,10 +428,6 @@ type chunkedReader struct {
err
os
.
Error
}
func
newChunkedReader
(
r
*
bufio
.
Reader
)
*
chunkedReader
{
return
&
chunkedReader
{
r
:
r
}
}
func
(
cr
*
chunkedReader
)
beginChunk
()
{
// chunk-size CRLF
var
line
string
...
...
src/pkg/http/transfer.go
View file @
7983ab9d
...
...
@@ -279,7 +279,7 @@ func readTransfer(msg interface{}, r *bufio.Reader) (err os.Error) {
// or close connection when finished, since multipart is not supported yet
switch
{
case
chunked
(
t
.
TransferEncoding
)
:
t
.
Body
=
&
body
{
Reader
:
n
ewChunkedReader
(
r
),
hdr
:
msg
,
r
:
r
,
closing
:
t
.
Close
}
t
.
Body
=
&
body
{
Reader
:
N
ewChunkedReader
(
r
),
hdr
:
msg
,
r
:
r
,
closing
:
t
.
Close
}
case
t
.
ContentLength
>=
0
:
// TODO: limit the Content-Length. This is an easy DoS vector.
t
.
Body
=
&
body
{
Reader
:
io
.
LimitReader
(
r
,
t
.
ContentLength
),
closing
:
t
.
Close
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment