Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
cb375ffb
Commit
cb375ffb
authored
Apr 30, 2011
by
Brad Fitzpatrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: new error for reading a body after it's been closed
R=adg CC=golang-dev
https://golang.org/cl/4433094
parent
0d1f76de
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
src/pkg/http/transfer.go
src/pkg/http/transfer.go
+20
-0
No files found.
src/pkg/http/transfer.go
View file @
cb375ffb
...
...
@@ -439,9 +439,29 @@ type body struct {
hdr
interface
{}
// non-nil (Response or Request) value means read trailer
r
*
bufio
.
Reader
// underlying wire-format reader for the trailer
closing
bool
// is the connection to be closed after reading body?
closed
bool
}
// ErrBodyReadAferClose is returned when reading a Request Body after
// the body has been closed. This typically happens when the body is
// read after an HTTP Handler calls WriteHeader or Write on its
// ResponseWriter.
var
ErrBodyReadAferClose
=
os
.
NewError
(
"http: invalid Read on closed request Body"
)
func
(
b
*
body
)
Read
(
p
[]
byte
)
(
n
int
,
err
os
.
Error
)
{
if
b
.
closed
{
return
0
,
ErrBodyReadAferClose
}
return
b
.
Reader
.
Read
(
p
)
}
func
(
b
*
body
)
Close
()
os
.
Error
{
if
b
.
closed
{
return
nil
}
defer
func
()
{
b
.
closed
=
true
}()
if
b
.
hdr
==
nil
&&
b
.
closing
{
// no trailer and closing the connection next.
// no point in reading to EOF.
...
...
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