Merge branch 'pr'

master
tanghc 3 years ago
commit 19022bdbe1
  1. 14
      sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/impl/EurekaUri.java

@ -5,6 +5,8 @@ import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.internal.http.HttpMethod; import okhttp3.internal.http.HttpMethod;
import java.util.Base64;
/** /**
* https://github.com/Netflix/eureka/wiki/Eureka-REST-operations * https://github.com/Netflix/eureka/wiki/Eureka-REST-operations
* *
@ -64,12 +66,16 @@ public enum EurekaUri {
url = url.substring(0, url.length() - 1); url = url.substring(0, url.length() - 1);
} }
String requestUrl = url + getUri(args); String requestUrl = url + getUri(args);
Request request = this.getBuilder() Request.Builder builder = this.getBuilder()
.url(requestUrl) .url(requestUrl)
.addHeader("Content-Type", "application/json") .addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json") .addHeader("Accept", "application/json");
.build(); //是否开启 Basic
return request; if(url.contains("@") && url.contains(":")){
String user = url.split("@")[0].replace("http://","").replace("https://","");
builder.addHeader("Authorization","Basic " + Base64.getUrlEncoder().encodeToString(user.getBytes()));
}
return builder.build();
} }
public Request.Builder getBuilder() { public Request.Builder getBuilder() {

Loading…
Cancel
Save