From 00431a85561b18f41c31378ddbb8788cf14eaa59 Mon Sep 17 00:00:00 2001 From: LeeGene <1670044143@qq.com> Date: Thu, 21 Sep 2023 10:48:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dv1.1.17=E7=89=88=E6=9C=ACbug?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81python=E5=A4=8D=E7=94=A8session?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- libs/types.go | 1 + libs_dist/export.go | 12 +++++++++++- version.go | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 166851e..c5cd681 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # requests -[![Gitee link address](https://img.shields.io/badge/gitee-reference-red?logo=gitee&logoColor=red&labelColor=white)](https://gitee.com/leegene/requests)[![Github link address](https://img.shields.io/badge/github-reference-blue?logo=github&logoColor=black&labelColor=white&color=black)](https://github.com/wangluozhe/requests)[![Go Version](https://img.shields.io/badge/Go%20Version-1.20-blue?logo=go&logoColor=white&labelColor=gray)]()[![Release Version](https://img.shields.io/badge/release-v1.1.17-blue)]()[![go documentation](https://img.shields.io/badge/go-documentation-blue)](https://pkg.go.dev/github.com/wangluozhe/requests)[![license GPL-3.0](https://img.shields.io/badge/license-GPL3.0-orange)](https://github.com/wangluozhe/requests/blob/main/LICENSE) +[![Gitee link address](https://img.shields.io/badge/gitee-reference-red?logo=gitee&logoColor=red&labelColor=white)](https://gitee.com/leegene/requests)[![Github link address](https://img.shields.io/badge/github-reference-blue?logo=github&logoColor=black&labelColor=white&color=black)](https://github.com/wangluozhe/requests)[![Go Version](https://img.shields.io/badge/Go%20Version-1.20-blue?logo=go&logoColor=white&labelColor=gray)]()[![Release Version](https://img.shields.io/badge/release-v1.1.18-blue)]()[![go documentation](https://img.shields.io/badge/go-documentation-blue)](https://pkg.go.dev/github.com/wangluozhe/requests)[![license GPL-3.0](https://img.shields.io/badge/license-GPL3.0-orange)](https://github.com/wangluozhe/requests/blob/main/LICENSE) requests支持以下新特性: diff --git a/libs/types.go b/libs/types.go index 3516c58..42911c3 100644 --- a/libs/types.go +++ b/libs/types.go @@ -1,6 +1,7 @@ package libs type RequestParams struct { + Id string `json:"Id"` Method string `json:"Method"` Url string `json:"Url"` Params map[string]string `json:"Params"` diff --git a/libs_dist/export.go b/libs_dist/export.go index f90c620..833df53 100644 --- a/libs_dist/export.go +++ b/libs_dist/export.go @@ -23,6 +23,16 @@ import ( var unsafePointers = make(map[string]*C.char) var unsafePointersLock = sync.Mutex{} var errorFormat = "{\"err\": \"%v\"}" +var session = make(map[string]*requests.Session) + +func GetSession(id string) *requests.Session { + if ss, ok := session[id]; ok { + return ss + } + ss := requests.NewSession() + session[id] = ss + return ss +} //export request func request(requestParamsChar *C.char) *C.char { @@ -37,7 +47,7 @@ func request(requestParamsChar *C.char) *C.char { if c_err != nil { return c_err } - response, err := requests.Request(requestParams.Method, requestParams.Url, req) + response, err := GetSession(requestParams.Id).Request(requestParams.Method, requestParams.Url, req) if err != nil { return C.CString(fmt.Sprintf(errorFormat, err.Error())) } diff --git a/version.go b/version.go index 3941c5b..ba8f422 100644 --- a/version.go +++ b/version.go @@ -2,6 +2,6 @@ package requests const ( NAME = "golang-requests" // 名称 - VERSION = "1.1.17" // 当前版本 + VERSION = "1.1.18" // 当前版本 USER_AGENT = NAME + VERSION // UA )