From 6f0aee1cc55b0ce593d282ab7d8b530e2c392ff6 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 23 May 2019 20:43:09 +0800 Subject: [PATCH 1/2] version updates --- version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.go b/version.go index 6589dd5ed..76fc245fa 100644 --- a/version.go +++ b/version.go @@ -1,4 +1,4 @@ package gf -const VERSION = "v1.6.14" +const VERSION = "v1.6.15" const AUTHORS = "john" From 592bf76eb04550ebe93938d367ffce93f42a0e49 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 23 May 2019 21:20:46 +0800 Subject: [PATCH 2/2] add browser mode support for ghttp.Client.Post --- g/net/ghttp/ghttp_client_request.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/g/net/ghttp/ghttp_client_request.go b/g/net/ghttp/ghttp_client_request.go index e907e8297..0178492d5 100644 --- a/g/net/ghttp/ghttp_client_request.go +++ b/g/net/ghttp/ghttp_client_request.go @@ -180,6 +180,17 @@ func (c *Client) Post(url string, data...interface{}) (*ClientResponse, error) { cookies : make(map[string]string), } r.Response = resp + // 浏览器模式 + if c.browserMode { + now := time.Now() + for _, v := range r.Cookies() { + if v.Expires.UnixNano() < now.UnixNano() { + delete(c.cookies, v.Name) + } else { + c.cookies[v.Name] = v.Value + } + } + } return r, nil } @@ -258,7 +269,7 @@ func (c *Client) DoRequestContent(method string, url string, data...interface{}) return string(response.ReadAll()) } -// 请求并返回response对象,该方法支持二进制提交数据 +// 请求并返回response对象 func (c *Client) DoRequest(method, url string, data...interface{}) (*ClientResponse, error) { if strings.EqualFold("POST", method) { return c.Post(url, data...)