|
|
@@ -57,6 +57,7 @@ public class HttpConnector implements WsConnector { |
|
|
|
*/ |
|
|
|
private final HttpUrl baseUrl; |
|
|
|
private final String credentials; |
|
|
|
private final String systemPassCode; |
|
|
|
private final OkHttpClient okHttpClient; |
|
|
|
|
|
|
|
private HttpConnector(Builder builder) { |
|
|
@@ -74,6 +75,7 @@ public class HttpConnector implements WsConnector { |
|
|
|
// the Basic credentials consider an empty password. |
|
|
|
this.credentials = Credentials.basic(builder.login, nullToEmpty(builder.password)); |
|
|
|
} |
|
|
|
this.systemPassCode = builder.systemPassCode; |
|
|
|
okHttpClientBuilder.setProxy(builder.proxy); |
|
|
|
okHttpClientBuilder.setProxyLogin(builder.proxyLogin); |
|
|
|
okHttpClientBuilder.setProxyPassword(builder.proxyPassword); |
|
|
@@ -164,6 +166,9 @@ public class HttpConnector implements WsConnector { |
|
|
|
if (credentials != null) { |
|
|
|
okHttpRequestBuilder.header("Authorization", credentials); |
|
|
|
} |
|
|
|
if (systemPassCode != null) { |
|
|
|
okHttpRequestBuilder.header("X-Sonar-Passcode", systemPassCode); |
|
|
|
} |
|
|
|
getRequest.getHeaders().getNames().forEach(name -> |
|
|
|
okHttpRequestBuilder.header(name, getRequest.getHeaders().getValue(name).get())); |
|
|
|
return okHttpRequestBuilder; |
|
|
@@ -194,6 +199,7 @@ public class HttpConnector implements WsConnector { |
|
|
|
private Proxy proxy; |
|
|
|
private String proxyLogin; |
|
|
|
private String proxyPassword; |
|
|
|
private String systemPassCode; |
|
|
|
private int connectTimeoutMs = DEFAULT_CONNECT_TIMEOUT_MILLISECONDS; |
|
|
|
private int readTimeoutMs = DEFAULT_READ_TIMEOUT_MILLISECONDS; |
|
|
|
private SSLSocketFactory sslSocketFactory = null; |
|
|
@@ -288,6 +294,11 @@ public class HttpConnector implements WsConnector { |
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
|
public Builder systemPassCode(@Nullable String systemPassCode) { |
|
|
|
this.systemPassCode = systemPassCode; |
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
|
public HttpConnector build() { |
|
|
|
checkArgument(!isNullOrEmpty(url), "Server URL is not defined"); |
|
|
|
return new HttpConnector(this); |