mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
add io.LimitReader.
use it to limit data read from http.Request Body R=r DELTA=32 (8 added, 6 deleted, 18 changed) OCL=33899 CL=33916
This commit is contained in:
parent
29415d0557
commit
90dcd5face
2 changed files with 22 additions and 20 deletions
|
|
@ -142,6 +142,12 @@ func send(req *Request) (resp *Response, err os.Error) {
|
|||
r := io.Reader(reader);
|
||||
if v := resp.GetHeader("Transfer-Encoding"); v == "chunked" {
|
||||
r = newChunkedReader(reader);
|
||||
} else if v := resp.GetHeader("Content-Length"); v != "" {
|
||||
n, err := strconv.Atoi64(v);
|
||||
if err != nil {
|
||||
return nil, &badStringError{"invalid Content-Length", v};
|
||||
}
|
||||
r = io.LimitReader(r, n);
|
||||
}
|
||||
resp.Body = readClose{ r, conn };
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue