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
15da069a
Commit
15da069a
authored
Feb 04, 2010
by
Petar Maymounkov
Committed by
Russ Cox
Feb 04, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: use ChunkWriter in Request.Write
R=rsc CC=golang-dev
https://golang.org/cl/196079
parent
43d2e59a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
27 deletions
+15
-27
request.go
src/pkg/http/request.go
+15
-27
No files found.
src/pkg/http/request.go
View file @
15da069a
...
...
@@ -181,33 +181,21 @@ func (req *Request) Write(w io.Writer) os.Error {
io
.
WriteString
(
w
,
"
\r\n
"
)
if
req
.
Body
!=
nil
{
buf
:=
make
([]
byte
,
chunkSize
)
Loop
:
for
{
var
nr
,
nw
int
var
er
,
ew
os
.
Error
if
nr
,
er
=
req
.
Body
.
Read
(
buf
);
nr
>
0
{
if
er
==
nil
||
er
==
os
.
EOF
{
fmt
.
Fprintf
(
w
,
"%x
\r\n
"
,
nr
)
nw
,
ew
=
w
.
Write
(
buf
[
0
:
nr
])
fmt
.
Fprint
(
w
,
"
\r\n
"
)
}
}
switch
{
case
er
!=
nil
:
if
er
==
os
.
EOF
{
break
Loop
}
return
er
case
ew
!=
nil
:
return
ew
case
nw
<
nr
:
return
io
.
ErrShortWrite
}
}
req
.
Body
.
Close
()
// last-chunk CRLF
fmt
.
Fprint
(
w
,
"0
\r\n\r\n
"
)
cw
:=
NewChunkedWriter
(
w
)
if
_
,
err
:=
io
.
Copy
(
cw
,
req
.
Body
);
err
!=
nil
{
return
err
}
if
err
:=
cw
.
Close
();
err
!=
nil
{
return
err
}
// TODO(petar): Write trailer here and append \r\n. For now, we
// simply send the final \r\n:
if
_
,
err
:=
fmt
.
Fprint
(
w
,
"
\r\n
"
);
err
!=
nil
{
return
err
}
if
err
:=
req
.
Body
.
Close
();
err
!=
nil
{
return
err
}
}
return
nil
...
...
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