Commit a22e7a1e authored by wang's avatar wang

每次请求后关闭连接

parent 82428bca
......@@ -38,7 +38,7 @@ require (
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
......
......@@ -131,6 +131,8 @@ golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
......
......@@ -100,7 +100,7 @@ func (c *Client) GetSessionCookies() map[string]string {
}
func (c *Client) GetText() string {
defer c.Response.Body.Close()
//http.DecompressBody(c.Response)
//rb, _ := io.ReadAll(c.Response.Body)
content, _ := ioutil.ReadAll(c.Response.Body)
......@@ -127,8 +127,8 @@ var chromes = []profiles.ClientProfile{
//profiles.Chrome_110,
//profiles.Chrome_107,
//profiles.Chrome_108,
//profiles.Chrome_117,
profiles.Firefox_120,
profiles.Chrome_117,
//profiles.Firefox_120,
//profiles.Safari_15_6_1,
//profiles.Safari_16_0,
//tls_client.Safari_Ipad_15_6,
......@@ -165,6 +165,7 @@ func NewClient(forWard ForwardItem, ios bool) (Client, error) {
if err != nil {
return Client{}, err
}
return Client{Client: client, Item: forWard, Jar: jar, TlsVersion: tlsVersion.GetClientHelloStr()}, nil
}
......
......@@ -57,7 +57,13 @@ func ForwardIOS(c *gin.Context) {
res["cost_time"] = time.Now().Sub(t1).Milliseconds()
res["url"] = client.GetRespUrl()
res["text"] = client.GetText()
defer func() {
err := client.Response.Body.Close()
if err != nil {
fmt.Errorf("text %s", err.Error())
return
}
}()
logrus.Infof("%s 转发 %s %s %d 耗时 %s", client.TlsVersion, forWard.Url, forWard.Proxy, client.GetStatusCode(), time.Now().Sub(t1).String())
c.JSON(200, res)
}
......@@ -99,7 +105,14 @@ func Forward(c *gin.Context) {
res["cost_time"] = time.Now().Sub(t1).Milliseconds()
res["url"] = client.GetRespUrl()
res["text"] = client.GetText()
defer func() {
err := client.Response.Body.Close()
if err != nil {
fmt.Errorf("text %s", err.Error())
return
}
}()
client.Client.CloseIdleConnections()
logrus.Infof("%s 转发 %s %s %d 耗时 %s", client.TlsVersion, forWard.Url, forWard.Proxy, client.GetStatusCode(), time.Now().Sub(t1).String())
c.JSON(200, res)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment