Java 类com.intellij.util.net.IdeHttpClientHelpers 实例源码

项目:hybris-integration-intellij-idea-plugin    文件:StatsRequest.java   
@Override
public StatsResponse call() throws Exception {
    final RequestConfig.Builder builder = RequestConfig
        .custom()
        .setConnectTimeout(TIMEOUT)
        .setConnectionRequestTimeout(TIMEOUT)
        .setSocketTimeout(TIMEOUT);
    IdeHttpClientHelpers.ApacheHttpClient4.setProxyForUrlIfEnabled(builder, HybrisConstants.STATS_COLLECTOR_URL);
    final RequestConfig config = builder.build();
    final HttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(config).build();

    final List<NameValuePair> patchedUrlParameters = ContainerUtil.newArrayList(urlParameters);
    patchUrlParameters(patchedUrlParameters);
    final HttpPost post = new HttpPost(HybrisConstants.STATS_COLLECTOR_URL);
    post.setEntity(new UrlEncodedFormEntity(patchedUrlParameters, UTF_8));
    return new StatsResponse(client.execute(post));
}
项目:intellij-ce-playground    文件:AuthenticationService.java   
@NotNull
private HttpClient getClient(@NotNull SVNURL repositoryUrl) {
  // TODO: Implement algorithm of resolving necessary enabled protocols (TLSv1 vs SSLv3) instead of just using values from Settings.
  SSLContext sslContext = createSslContext(repositoryUrl);
  List<String> supportedProtocols = getSupportedSslProtocols();
  SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(sslContext, ArrayUtil.toStringArray(supportedProtocols), null,
                                                                            SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
  // TODO: Seems more suitable here to read timeout values directly from config file - without utilizing SvnAuthenticationManager.
  final RequestConfig.Builder requestConfigBuilder = RequestConfig.custom();
  final BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
  if (haveDataForTmpConfig()) {
    IdeHttpClientHelpers.ApacheHttpClient4.setProxyIfEnabled(requestConfigBuilder);
    IdeHttpClientHelpers.ApacheHttpClient4.setProxyCredentialsIfEnabled(credentialsProvider);
  }

  return HttpClients.custom()
    .setSSLSocketFactory(socketFactory)
    .setDefaultSocketConfig(SocketConfig.custom()
                              .setSoTimeout(getAuthenticationManager().getReadTimeout(repositoryUrl))
                              .build())
    .setDefaultRequestConfig(requestConfigBuilder
                               .setConnectTimeout(getAuthenticationManager().getConnectTimeout(repositoryUrl))
                               .build())
    .setDefaultCredentialsProvider(credentialsProvider)
    .build();
}
项目:consulo-tasks    文件:NewBaseRepositoryImpl.java   
@NotNull
private CredentialsProvider createCredentialsProvider()
{
    CredentialsProvider provider = new BasicCredentialsProvider();
    // Basic authentication
    if(isUseHttpAuthentication())
    {
        provider.setCredentials(BASIC_AUTH_SCOPE, new UsernamePasswordCredentials(getUsername(), getPassword()));
    }
    // Proxy authentication
    if(isUseProxy())
    {
        IdeHttpClientHelpers.ApacheHttpClient4.setProxyCredentialsForUrlIfEnabled(provider, getUrl());
    }

    return provider;
}
项目:intellij-ce-playground    文件:NewBaseRepositoryImpl.java   
@NotNull
private CredentialsProvider createCredentialsProvider() {
  CredentialsProvider provider = new BasicCredentialsProvider();
  // Basic authentication
  if (isUseHttpAuthentication()) {
    provider.setCredentials(BASIC_AUTH_SCOPE, new UsernamePasswordCredentials(getUsername(), getPassword()));
  }
  // Proxy authentication
  if (isUseProxy()) {
    IdeHttpClientHelpers.ApacheHttpClient4.setProxyCredentialsForUrlIfEnabled(provider, getUrl());
  }

  return provider;
}
项目:intellij-ce-playground    文件:NewBaseRepositoryImpl.java   
@NotNull
protected RequestConfig createRequestConfig() {
  TaskSettings tasksSettings = TaskSettings.getInstance();
  RequestConfig.Builder builder = RequestConfig.custom()
    .setConnectTimeout(3000)
    .setSocketTimeout(tasksSettings.CONNECTION_TIMEOUT);
  if (isUseProxy()) {
    IdeHttpClientHelpers.ApacheHttpClient4.setProxyForUrlIfEnabled(builder, getUrl());
  }

  return builder.build();
}
项目:intellij-ce-playground    文件:GithubConnection.java   
@NotNull
private static RequestConfig createRequestConfig(@NotNull GithubAuthData auth) {
  RequestConfig.Builder builder = RequestConfig.custom();

  int timeout = GithubSettings.getInstance().getConnectionTimeout();
  builder
    .setConnectTimeout(timeout)
    .setSocketTimeout(timeout);

  if (auth.isUseProxy()) {
    IdeHttpClientHelpers.ApacheHttpClient4.setProxyForUrlIfEnabled(builder, auth.getHost());
  }

  return builder.build();
}
项目:intellij-ce-playground    文件:GithubConnection.java   
@NotNull
private static CredentialsProvider createCredentialsProvider(@NotNull GithubAuthData auth) {
  CredentialsProvider provider = new BasicCredentialsProvider();
  // Basic authentication
  GithubAuthData.BasicAuth basicAuth = auth.getBasicAuth();
  if (basicAuth != null) {
    provider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(basicAuth.getLogin(), basicAuth.getPassword()));
  }

  if (auth.isUseProxy()) {
    IdeHttpClientHelpers.ApacheHttpClient4.setProxyCredentialsForUrlIfEnabled(provider, auth.getHost());
  }

  return provider;
}
项目:consulo-tasks    文件:NewBaseRepositoryImpl.java   
@NotNull
protected RequestConfig createRequestConfig()
{
    TaskSettings tasksSettings = TaskSettings.getInstance();
    RequestConfig.Builder builder = RequestConfig.custom().setConnectTimeout(3000).setSocketTimeout(tasksSettings.CONNECTION_TIMEOUT);
    if(isUseProxy())
    {
        IdeHttpClientHelpers.ApacheHttpClient4.setProxyForUrlIfEnabled(builder, getUrl());
    }

    return builder.build();
}