1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

optimize the resource of using resttemplate in 1.x

This commit is contained in:
fangjian0423 2019-03-18 14:19:04 +08:00
parent 8049bda076
commit d4d18c33b1
2 changed files with 3 additions and 2 deletions

View File

@ -16,7 +16,7 @@
"strategy": 0 "strategy": 0
}, },
{ {
"resource": "http://www.taobao.com", "resource": "GET:http://www.taobao.com",
"controlBehavior": 0, "controlBehavior": 0,
"count": 0, "count": 0,
"grade": 1, "grade": 1,

View File

@ -52,7 +52,8 @@ public class SentinelProtectInterceptor implements ClientHttpRequestInterceptor
public ClientHttpResponse intercept(HttpRequest request, byte[] body, public ClientHttpResponse intercept(HttpRequest request, byte[] body,
ClientHttpRequestExecution execution) throws IOException { ClientHttpRequestExecution execution) throws IOException {
URI uri = request.getURI(); URI uri = request.getURI();
String hostResource = uri.getScheme() + "://" + uri.getHost() String hostResource = request.getMethod().toString() + ":" + uri.getScheme()
+ "://" + uri.getHost()
+ (uri.getPort() == -1 ? "" : ":" + uri.getPort()); + (uri.getPort() == -1 ? "" : ":" + uri.getPort());
String hostWithPathResource = hostResource + uri.getPath(); String hostWithPathResource = hostResource + uri.getPath();
boolean entryWithPath = true; boolean entryWithPath = true;