You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/01/04 08:18:37 UTC

[GitHub] little-cui closed pull request #240: SCB-161 Optimize restful client.

little-cui closed pull request #240: SCB-161 Optimize restful client.
URL: https://github.com/apache/incubator-servicecomb-service-center/pull/240
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/pkg/rest/client.go b/pkg/rest/client.go
index 361c1c8d..3ce4e29c 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  ????????


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services