mirror of
https://gitee.com/johng/gf.git
synced 2024-12-05 13:48:09 +08:00
33 lines
719 B
Go
33 lines
719 B
Go
// 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.
|
|
// HTTP客户端请求返回.
|
|
|
|
package ghttp
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"net/http"
|
|
)
|
|
|
|
// 客户端请求结果对象
|
|
type ClientResponse struct {
|
|
http.Response
|
|
}
|
|
|
|
// 获取返回的数据
|
|
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()
|
|
} |