http.go
func (resp *Response) ReadLimitBody(r *bufio.Reader, maxBodySize int) error {
	resp.resetSkipHeader()
	err := resp.Header.Read(r)
	if err != nil {
		return err
	}
	if resp.Header.StatusCode() == StatusContinue {
		// Read the next response according to http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html .
		if err = resp.Header.Read(r); err != nil {
			return err
		}
	}

	if !resp.mustSkipBody() {
		bodyBuf := resp.bodyBuffer()
		bodyBuf.Reset()
		bodyBuf.B, err = readBody(r, resp.Header.ContentLength(), maxBodySize, bodyBuf.B)
		if err != nil {
			return err
		}
		resp.Header.SetContentLength(len(bodyBuf.B))
	}
	return nil
}
func (resp *Response) ReadLimitBody(r *bufio.Reader, maxBodySize int) error {
	resp.resetSkipHeader()
	err := resp.Header.Read(r)
	if err != nil {
		return err
	}
	if resp.Header.StatusCode() == StatusContinue {
		// Read the next response according to http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html .
		if err = resp.Header.Read(r); err != nil {
			return err
		}
	}

	if !resp.mustSkipBody() {
		bodyBuf := resp.bodyBuffer()
		bodyBuf.Reset()
		bodyBuf.B, err = readBody(r, resp.Header.ContentLength(), maxBodySize, bodyBuf.B)
		if err != nil {
			return err
		}
		resp.Header.SetContentLength(len(bodyBuf.B))
	}
	return nil
}
func ( resp * Response ) ReadLimitBody ( r * bufio . Reader , maxBodySize int ) error { resp . resetSkipHeader ( ) err := resp . Header . Read ( r ) if err != nil { return err } if resp . Header . StatusCode ( ) == StatusContinue { // Read the next response according to http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html . if err = resp . Header . Read ( r ) ; err != nil { return err } } if ! resp . mustSkipBody ( ) { bodyBuf := resp . bodyBuffer ( ) bodyBuf . Reset ( ) bodyBuf . B , err = readBody ( r , resp . Header . ContentLength ( ) , maxBodySize , bodyBuf . B ) if err != nil { return err } resp . Header . SetContentLength ( len ( bodyBuf . B ) ) } return nil }
// ReadLimitBody reads response from the given r, limiting the body size.
//
// If maxBodySize > 0 and the body size exceeds maxBodySize,
// then ErrBodyTooLarge is returned.
//
// io.EOF is returned if r is closed before reading the first header byte.
ReadLimitBody reads response from the given r limiting the body size . If maxBodySize > 0 and the body size exceeds maxBodySize then ErrBodyTooLarge is returned . io . EOF is returned if r is closed before reading the first header byte .