Files
gf/g/net/ghttp/ghttp_client_response.go

33 lines
719 B
Go
Raw Normal View History

2017-12-29 16:03:30 +08:00
// Copyright 2017 gf Author(https://gitee.com/johng/gf). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://gitee.com/johng/gf.
2018-04-13 15:19:31 +08:00
// HTTP客户端请求返回.
2017-12-31 18:19:58 +08:00
2017-12-07 14:57:16 +08:00
package ghttp
import (
"io/ioutil"
2018-01-02 16:35:13 +08:00
"net/http"
2017-12-07 14:57:16 +08:00
)
2018-01-02 16:35:13 +08:00
// 客户端请求结果对象
type ClientResponse struct {
http.Response
}
2017-12-07 14:57:16 +08:00
// 获取返回的数据
func (r *ClientResponse) ReadAll() []byte {
body, err := ioutil.ReadAll(r.Body)
if err != nil {
return nil
}
return body
}
// 关闭返回的HTTP链接
func (r *ClientResponse) Close() {
r.Response.Close = true
r.Body.Close()
}