mirror of
https://github.com/gospider007/requests.git
synced 2025-12-24 13:57:52 +08:00
add IsStream
This commit is contained in:
@@ -193,7 +193,7 @@ func (obj *Client) Request(ctx context.Context, method string, href string, opti
|
||||
func (obj *Client) request(ctx context.Context, option *RequestOption) (response *Response, err error) {
|
||||
response = new(Response)
|
||||
defer func() {
|
||||
if err == nil && !response.oneceAlive() {
|
||||
if err == nil && !response.IsStream() {
|
||||
err = response.ReadBody()
|
||||
defer response.CloseBody()
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ func (obj *Response) Read(con []byte) (i int, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (obj *Response) oneceAlive() bool {
|
||||
func (obj *Response) IsStream() bool {
|
||||
return obj.webSocket != nil || obj.sseClient != nil || obj.stream
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user