org.eclipse.jetty.client.HttpClient.setFollowRedirects()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(210)

本文整理了Java中org.eclipse.jetty.client.HttpClient.setFollowRedirects()方法的一些代码示例,展示了HttpClient.setFollowRedirects()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.setFollowRedirects()方法的具体详情如下:
包路径:org.eclipse.jetty.client.HttpClient
类名称:HttpClient
方法名:setFollowRedirects

HttpClient.setFollowRedirects介绍

暂无

代码示例

代码示例来源:origin: konsoletyper/teavm

public CodeServlet(String mainClass, String[] classPath) {
  this.mainClass = mainClass;
  this.classPath = classPath.clone();
  httpClient = new HttpClient();
  httpClient.setFollowRedirects(false);
}

代码示例来源:origin: xuxueli/xxl-job

try {
  httpClient = new HttpClient();
  httpClient.setFollowRedirects(false);	// Configure HttpClient, for example:

代码示例来源:origin: xuxueli/xxl-job

try {
  httpClient = new HttpClient();
  httpClient.setFollowRedirects(false);	// Configure HttpClient, for example:

代码示例来源:origin: sixt/ja-micro

private HttpClient createHttpClient() {
  SslContextFactory sslContextFactory = new SslContextFactory();
  sslContextFactory.setExcludeCipherSuites("");
  HttpClient client = new HttpClient(sslContextFactory);
  client.setFollowRedirects(false);
  client.setMaxConnectionsPerDestination(2);
  //You can set more restrictive timeouts per request, but not less, so
  //  we set the maximum timeout of 1 hour here.
  client.setIdleTimeout(60 * 60 * 1000);
  try {
    client.start();
  } catch (Exception e) {
    logger.error("Error building http client", e);
  }
  return client;
}

代码示例来源:origin: sixt/ja-micro

@Provides
public HttpClient getHttpClient() {
  HttpClient client = new HttpClient();
  client.setFollowRedirects(false);
  client.setMaxConnectionsPerDestination(32);
  client.setConnectTimeout(100);
  client.setAddressResolutionTimeout(100);
  //You can set more restrictive timeouts per request, but not less, so
  //  we set the maximum timeout of 1 hour here.
  client.setIdleTimeout(60 * 60 * 1000);
  try {
    client.start();
  } catch (Exception e) {
    logger.error("Error building http client", e);
  }
  return client;
}

代码示例来源:origin: sixt/ja-micro

private HttpClient createHttpClient() {
  //Allow ssl by default
  SslContextFactory sslContextFactory = new SslContextFactory();
  //Don't exclude RSA because Sixt needs them, dammit!
  sslContextFactory.setExcludeCipherSuites("");
  HttpClient client = new HttpClient(sslContextFactory);
  client.setFollowRedirects(false);
  client.setMaxConnectionsPerDestination(16);
  client.setRequestBufferSize(65536);
  client.setConnectTimeout(FeatureFlags.getHttpConnectTimeout(serviceProperties));
  client.setAddressResolutionTimeout(FeatureFlags.getHttpAddressResolutionTimeout(serviceProperties));
  //You can set more restrictive timeouts per request, but not less, so
  //  we set the maximum timeout of 1 hour here.
  client.setIdleTimeout(60 * 60 * 1000);
  try {
    client.start();
  } catch (Exception e) {
    logger.error("Error building http client", e);
  }
  return client;
}

代码示例来源:origin: danielflower/app-runner

public void blockUntilReady() throws Exception {
  client.setFollowRedirects(false);
  client.start();
  long start = System.currentTimeMillis();
  while ((System.currentTimeMillis() - start) < unit.toMillis(timeout)) {
    Thread.sleep(POLL_INTERVAL);
    if (predicate.test(client)) {
      return;
    }
    log.info("Waiting for start up of " + name);
  }
  throw new TimeoutException();
}

代码示例来源:origin: org.eclipse.jetty.spdy/spdy-http-server

private void configureHttpClient(HttpClient httpClient)
{
  // Redirects must be proxied as is, not followed
  httpClient.setFollowRedirects(false);
  // Must not store cookies, otherwise cookies of different clients will mix
  httpClient.setCookieStore(new HttpCookieStore.Empty());
}

代码示例来源:origin: RusticiSoftware/TinCanJava

private static HttpClient httpClient() throws Exception {
  if (_httpClient == null ) {
    _httpClient = new HttpClient(new SslContextFactory());
    _httpClient.setConnectTimeout(TIMEOUT_CONNECT);
    _httpClient.setFollowRedirects(false);
    _httpClient.setCookieStore(new HttpCookieStore.Empty());
    _httpClient.start();
    _ourClient = true;
  }
  return _httpClient;
}

代码示例来源:origin: stackoverflow.com

/*配置sslcontextfactory处理https请求*/
    SslContextFactory sslContextFactory = new SslContextFactory();
    HttpClient httpClient = new HttpClient(sslContextFactory);
    httpClient.setFollowRedirects(false);
    httpClient.start();

    /*配置post请求的url、body、以及请求头*/
    Request request =  httpClient.POST("https://a1.easemob.com/yinshenxia/yinshenxia/users");
    request.header(HttpHeader.CONTENT_TYPE, "application/json");
    request.content(new StringContentProvider("{\"username\":\"jliu\",\"password\":\"123456\"}","utf-8"));
//      request.param("username", "jliu");
//      request.param("password", "123456");
    ContentResponse response = request.send();
    String res = new String(response.getContent());
    System.out.println(res);
    httpClient.stop();

代码示例来源:origin: danielflower/app-runner

private HttpClient createClient() throws Exception {
  int selectors = Math.max(1, Runtime.getRuntime().availableProcessors() / 2);
  HttpClient client = new HttpClient(new HttpClientTransportOverHTTP(selectors), new SslContextFactory(true));
  client.setFollowRedirects(false);
  client.setCookieStore(new HttpCookieStore.Empty());
  client.setMaxConnectionsPerDestination(256);
  client.setAddressResolutionTimeout(15000);
  client.setConnectTimeout(15000);
  client.setIdleTimeout(idleTimeout);
  client.setUserAgentField(null);
  client.start();
  client.getContentDecoderFactories().clear();
  return client;
}

代码示例来源:origin: org.apache.pulsar/pulsar-proxy

client.setFollowRedirects(true);

代码示例来源:origin: org.eclipse.jetty/jetty-proxy

client.setFollowRedirects(false);

代码示例来源:origin: isucon/isucon5-qualify

private HttpClient client() {
 HttpField agent = new HttpField("User-Agent", config.agent);
 HttpClient httpClient = new HttpClient();
 httpClient.setFollowRedirects(false);
 httpClient.setMaxConnectionsPerDestination(MAX_CONNECTIONS_PER_DEST);
 httpClient.setMaxRequestsQueuedPerDestination(MAX_QUEUED_REQUESTS_PER_DEST);
 httpClient.setUserAgentField(agent);
 httpClient.setCookieStore(new HttpCookieStore.Empty());
 return httpClient;
}

代码示例来源:origin: io.digdag/digdag-standards

private HttpClient client()
{
  boolean insecure = params.get("insecure", boolean.class, false);
  HttpClient httpClient = new HttpClient(new SslContextFactory(insecure));
  configureProxy(httpClient);
  boolean followRedirects = params.get("follow_redirects", boolean.class, true);
  httpClient.setFollowRedirects(followRedirects);
  httpClient.setMaxRedirects(maxRedirects);
  httpClient.setUserAgentField(new HttpField(
      USER_AGENT, userAgent + ' ' + httpClient.getUserAgentField().getValue()));
  try {
    httpClient.start();
  }
  catch (Exception e) {
    throw new TaskExecutionException(e);
  }
  return httpClient;
}

代码示例来源:origin: isucon/isucon5-final

private HttpClient client() {
  HttpField agent = new HttpField("User-Agent", config.agent);
  // TODO: non-keepalived client connections
  HttpClient httpClient = new HttpClient();
  httpClient.setFollowRedirects(false);
  httpClient.setMaxConnectionsPerDestination(MAX_CONNECTIONS_PER_DEST);
  httpClient.setMaxRequestsQueuedPerDestination(MAX_QUEUED_REQUESTS_PER_DEST);
  httpClient.setUserAgentField(agent);
  httpClient.setCookieStore(new HttpCookieStore.Empty());
  return httpClient;
}

代码示例来源:origin: org.apache.kafka/connect-runtime

client.setFollowRedirects(false);

代码示例来源:origin: jpos/jPOS-EE

httpClient.setFollowRedirects(false);

代码示例来源:origin: com.cisco.oss.foundation/http-client-jetty

@Override
protected void configureClient() {
  boolean addSslSupport = StringUtils.isNotEmpty(metadata.getKeyStorePath()) && StringUtils.isNotEmpty(metadata.getKeyStorePassword());
  if(addSslSupport){
    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStorePath(metadata.getKeyStorePath());
    sslContextFactory.setKeyStorePassword(metadata.getKeyStorePassword());
    boolean addTrustSupport = StringUtils.isNotEmpty(metadata.getTrustStorePath()) && StringUtils.isNotEmpty(metadata.getTrustStorePassword());
    if(addTrustSupport){
      sslContextFactory.setTrustStorePath(metadata.getTrustStorePath());
      sslContextFactory.setTrustStorePassword(metadata.getTrustStorePassword());
    }else{
      sslContextFactory.setTrustAll(true);
    }
    httpClient = new  HttpClient(sslContextFactory);
  }
  httpClient.setConnectTimeout(metadata.getConnectTimeout());
  httpClient.setIdleTimeout(metadata.getIdleTimeout());
  httpClient.setMaxConnectionsPerDestination(metadata.getMaxConnectionsPerAddress());
  httpClient.setMaxRequestsQueuedPerDestination(metadata.getMaxQueueSizePerAddress());
  httpClient.setFollowRedirects(followRedirects);
  try {
    httpClient.start();
  } catch (Exception e) {
    throw new ClientException("failed to start jetty http client: " + e, e);
  }
}

代码示例来源:origin: org.attribyte/attribyte-http

sslContextFactory.setExcludeCipherSuites("^.*_(MD5)$");
this.httpClient = new HttpClient(sslContextFactory);
this.httpClient.setFollowRedirects(options.followRedirects);
this.httpClient.setConnectTimeout(options.connectionTimeoutMillis);
this.httpClient.setMaxConnectionsPerDestination(options.maxConnectionsPerDestination);

相关文章

HttpClient类方法