mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-15 23:26:36 +08:00
优化HTTP客户端管理
This commit is contained in:
@@ -7,15 +7,17 @@ import (
|
||||
|
||||
// HTTPClient HTTP客户端
|
||||
type HTTPClient struct {
|
||||
rawClient *http.Client
|
||||
accessAt int64
|
||||
rawClient *http.Client
|
||||
accessAt int64
|
||||
isProxyProtocol bool
|
||||
}
|
||||
|
||||
// NewHTTPClient 获取新客户端对象
|
||||
func NewHTTPClient(rawClient *http.Client) *HTTPClient {
|
||||
func NewHTTPClient(rawClient *http.Client, isProxyProtocol bool) *HTTPClient {
|
||||
return &HTTPClient{
|
||||
rawClient: rawClient,
|
||||
accessAt: fasttime.Now().Unix(),
|
||||
rawClient: rawClient,
|
||||
accessAt: fasttime.Now().Unix(),
|
||||
isProxyProtocol: isProxyProtocol,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +36,11 @@ func (this *HTTPClient) AccessTime() int64 {
|
||||
return this.accessAt
|
||||
}
|
||||
|
||||
// IsProxyProtocol 判断是否为PROXY Protocol
|
||||
func (this *HTTPClient) IsProxyProtocol() bool {
|
||||
return this.isProxyProtocol
|
||||
}
|
||||
|
||||
// Close 关闭
|
||||
func (this *HTTPClient) Close() {
|
||||
this.rawClient.CloseIdleConnections()
|
||||
|
||||
Reference in New Issue
Block a user