You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/01/04 08:18:35 UTC
[incubator-servicecomb-service-center] branch master updated:
SCB-161 Optimize restful client. (#240)
This is an automated email from the ASF dual-hosted git repository.
littlecui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-service-center.git
The following commit(s) were added to refs/heads/master by this push:
new bd64771 SCB-161 Optimize restful client. (#240)
bd64771 is described below
commit bd6477106c97fae277812d4485a377632be11aae
Author: aseTo2016 <14...@qq.com>
AuthorDate: Thu Jan 4 16:18:33 2018 +0800
SCB-161 Optimize restful client. (#240)
SCB-161 Optimize restful client.
---
pkg/rest/client.go | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/pkg/rest/client.go b/pkg/rest/client.go
index 361c1c8..3ce4e29 100644
--- a/pkg/rest/client.go
+++ b/pkg/rest/client.go
@@ -30,6 +30,7 @@ import (
"net/http"
"reflect"
"time"
+ "net/url"
)
const (
@@ -117,7 +118,7 @@ func GetHttpsClient(gzip, verifyPeer bool) (client *HttpClient, err error) {
return getHttpsClient(gzip, verifyPeer, true, false)
}
-func GetClient(scheme string) (*HttpClient, error) {
+func getClientByScheme(scheme string) (*HttpClient, error) {
var err error
var client *HttpClient
if scheme == "https" {
@@ -136,6 +137,16 @@ func GetClient(scheme string) (*HttpClient, error) {
return client, nil
}
+func GetClient(urlPath string) (*HttpClient, error) {
+ var err error
+ urlParsed, err := url.Parse(urlPath)
+ if err != nil {
+ util.Logger().Errorf(err, "nonstandard url %s", urlPath)
+ return nil, err
+ }
+ return getClientByScheme(urlParsed.Scheme)
+}
+
/**
获取TLS认证HTTP客户端
gzip 控制是否支持压缩
--
To stop receiving notification emails like this one, please contact
['"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>'].