Compare commits

...

3 Commits

Author SHA1 Message Date
page 750c1d6363 Merge branch 'master' into dara2 2025-02-12 11:46:08 +08:00
peze 40fd48a7bb fix by compatible bug 2025-01-20 20:02:48 +08:00
dependabot[bot] b8dbae11d9 Bump golang.org/x/net from 0.22.0 to 0.26.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.22.0 to 0.26.0.
- [Commits](https://github.com/golang/net/compare/v0.22.0...v0.26.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-21 20:42:19 +08:00
6 changed files with 56 additions and 31 deletions
+8 -7
View File
@@ -25,10 +25,14 @@ import (
"github.com/alibabacloud-go/debug/debug"
"github.com/alibabacloud-go/tea/utils"
util "github.com/alibabacloud-go/tea-utils/v2/service"
"golang.org/x/net/proxy"
)
type RuntimeOptions = util.RuntimeOptions
type ExtendsParameters = util.ExtendsParameters
var debugLog = debug.Init("dara")
var hookDo = func(fn func(req *http.Request) (*http.Response, error)) func(req *http.Request) (*http.Response, error) {
@@ -64,11 +68,6 @@ type Response struct {
Headers map[string]*string
}
type ExtendsParameters struct {
Headers map[string]*string `json:"headers,omitempty" xml:"headers,omitempty"`
Queries map[string]*string `json:"queries,omitempty" xml:"queries,omitempty"`
}
// RuntimeObject is used for converting http configuration
type RuntimeObject struct {
IgnoreSSL *bool `json:"ignoreSSL" xml:"ignoreSSL"`
@@ -202,8 +201,10 @@ func getDaraClient(tag string) *daraClient {
}
// DoRequest is used send request to server
func DoRequest(request *Request, requestRuntime map[string]interface{}) (response *Response, err error) {
runtimeObject := NewRuntimeObject(requestRuntime)
func DoRequest(request *Request, runtimeObject *RuntimeObject) (response *Response, err error) {
if(runtimeObject == nil) {
runtimeObject = &RuntimeObject{}
}
fieldMap := make(map[string]string)
utils.InitLogMsg(fieldMap)
defer func() {
+13 -13
View File
@@ -509,7 +509,7 @@ func Test_DoRequest(t *testing.T) {
"tea": String("test"),
}
runtimeObj["httpsProxy"] = "# #%gfdf"
resp, err = DoRequest(request, runtimeObj)
resp, err = DoRequest(request, NewRuntimeObject(runtimeObj))
utils.AssertNil(t, resp)
utils.AssertContains(t, err.Error(), `invalid URL escape "%gf"`)
@@ -517,18 +517,18 @@ func Test_DoRequest(t *testing.T) {
request.Headers["tea"] = String("")
request.Headers["content-length"] = nil
runtimeObj["httpsProxy"] = "http://someuser:somepassword@ecs.aliyun.com"
resp, err = DoRequest(request, runtimeObj)
resp, err = DoRequest(request, NewRuntimeObject(runtimeObj))
utils.AssertNil(t, resp)
utils.AssertEqual(t, `Internal error`, err.Error())
request.Headers["host"] = String("tea-cn-hangzhou.aliyuncs.com:80")
request.Headers["user-agent"] = String("test")
resp, err = DoRequest(request, runtimeObj)
resp, err = DoRequest(request, NewRuntimeObject(runtimeObj))
utils.AssertNil(t, resp)
utils.AssertEqual(t, `Internal error`, err.Error())
runtimeObj["socks5Proxy"] = "# #%gfdf"
resp, err = DoRequest(request, runtimeObj)
resp, err = DoRequest(request, NewRuntimeObject(runtimeObj))
utils.AssertNil(t, resp)
utils.AssertContains(t, err.Error(), ` invalid URL escape "%gf"`)
@@ -539,7 +539,7 @@ func Test_DoRequest(t *testing.T) {
}
runtimeObj["socks5Proxy"] = "socks5://someuser:somepassword@ecs.aliyun.com"
runtimeObj["localAddr"] = "127.0.0.1"
resp, err = DoRequest(request, runtimeObj)
resp, err = DoRequest(request, NewRuntimeObject(runtimeObj))
utils.AssertNil(t, err)
utils.AssertEqual(t, "test", StringValue(resp.Headers["tea"]))
@@ -547,14 +547,14 @@ func Test_DoRequest(t *testing.T) {
runtimeObj["cert"] = "private certification"
runtimeObj["ca"] = "private ca"
runtimeObj["ignoreSSL"] = true
resp, err = DoRequest(request, runtimeObj)
resp, err = DoRequest(request, NewRuntimeObject(runtimeObj))
utils.AssertNil(t, err)
utils.AssertNotNil(t, resp)
// update the host is to restart a client
request.Headers["host"] = String("a.com")
runtimeObj["ignoreSSL"] = false
resp, err = DoRequest(request, runtimeObj)
resp, err = DoRequest(request, NewRuntimeObject(runtimeObj))
utils.AssertNotNil(t, err)
utils.AssertEqual(t, "tls: failed to find any PEM data in certificate input", err.Error())
utils.AssertNil(t, resp)
@@ -564,20 +564,20 @@ func Test_DoRequest(t *testing.T) {
runtimeObj["key"] = key
runtimeObj["cert"] = cert
runtimeObj["ca"] = "private ca"
_, err = DoRequest(request, runtimeObj)
_, err = DoRequest(request, NewRuntimeObject(runtimeObj))
utils.AssertNotNil(t, err)
utils.AssertEqual(t, "Failed to parse root certificate", err.Error())
// update the host is to restart a client
request.Headers["host"] = String("c.com")
runtimeObj["ca"] = ca
resp, err = DoRequest(request, runtimeObj)
resp, err = DoRequest(request, NewRuntimeObject(runtimeObj))
utils.AssertNil(t, err)
utils.AssertEqual(t, "test", StringValue(resp.Headers["tea"]))
request.Protocol = String("HTTP")
runtimeObj["ignoreSSL"] = false
resp, err = DoRequest(request, runtimeObj)
resp, err = DoRequest(request, NewRuntimeObject(runtimeObj))
utils.AssertNil(t, err)
utils.AssertEqual(t, "test", StringValue(resp.Headers["tea"]))
@@ -591,7 +591,7 @@ func Test_DoRequest(t *testing.T) {
request.Protocol = String("http")
request.Port = Int(1080)
request.Headers["host"] = String("tea-cn-hangzhou.aliyuncs.com")
resp, err = DoRequest(request, runtimeObj)
resp, err = DoRequest(request, NewRuntimeObject(runtimeObj))
utils.AssertNil(t, resp)
utils.AssertEqual(t, `Internal error`, err.Error())
}
@@ -608,9 +608,9 @@ func Test_DoRequestWithConcurrent(t *testing.T) {
for i := 0; i < 50; i++ {
wg.Add(1)
go func(readTimeout int) {
runtime := map[string]interface{}{
runtime := NewRuntimeObject(map[string]interface{}{
"readTimeout": readTimeout,
}
})
for j := 0; j < 50; j++ {
wg.Add(1)
go func() {
+1 -1
View File
@@ -19,7 +19,7 @@ type RetryPolicyContext struct {
RetriesAttempted int
HttpRequest *Request // placeholder for actual http.Request type
HttpResponse *Response // placeholder for actual http.Response type
Exception BaseError
Exception error
}
// BackoffPolicy interface with a method to get delay time
+4 -4
View File
@@ -17,8 +17,8 @@ type SSEEvent struct {
}
// 解析单个事件
func parseEvent(eventLines []string) SSEEvent {
var event SSEEvent
func parseEvent(eventLines []string) *SSEEvent {
var event *SSEEvent
var data string
var id string
@@ -77,8 +77,8 @@ func ReadAsString(body io.Reader) (string, error) {
return string(byt), nil
}
func ReadAsSSE(body io.ReadCloser) (<-chan SSEEvent, <-chan error) {
eventChannel := make(chan SSEEvent)
func ReadAsSSE(body io.ReadCloser) (<-chan *SSEEvent, <-chan error) {
eventChannel := make(chan *SSEEvent)
// 启动 Goroutine 解析 SSE 数据
go func() {
+2 -1
View File
@@ -4,9 +4,10 @@ go 1.14
require (
github.com/alibabacloud-go/debug v1.0.0
github.com/alibabacloud-go/tea-utils/v2 v2.0.7
github.com/clbanning/mxj/v2 v2.7.0
github.com/google/go-cmp v0.6.0 // indirect
github.com/json-iterator/go v1.1.12
github.com/modern-go/reflect2 v1.0.2
golang.org/x/net v0.22.0
golang.org/x/net v0.26.0
)
+28 -5
View File
@@ -1,5 +1,8 @@
github.com/alibabacloud-go/debug v1.0.0 h1:3eIEQWfay1fB24PQIEzXAswlVJtdQok8f3EVN5VrBnA=
github.com/alibabacloud-go/debug v1.0.0/go.mod h1:8gfgZCCAC3+SCzjWtY053FrOcd4/qlH6IHTI4QyICOc=
github.com/alibabacloud-go/tea v1.2.2/go.mod h1:CF3vOzEMAG+bR4WOql8gc2G9H3EkH3ZLAQdpmpXMgwk=
github.com/alibabacloud-go/tea-utils/v2 v2.0.7 h1:WDx5qW3Xa5ZgJ1c8NfqJkF6w+AU5wB8835UdhPr6Ax0=
github.com/alibabacloud-go/tea-utils/v2 v2.0.7/go.mod h1:qxn986l+q33J5VkialKMqT/TTs3E+U9MJpd001iWQ9I=
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME=
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -22,21 +25,31 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -44,22 +57,32 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=