当前位置: 首页>>代码示例>>Java>>正文


Java RedirectStrategy类代码示例

本文整理汇总了Java中org.apache.http.client.RedirectStrategy的典型用法代码示例。如果您正苦于以下问题:Java RedirectStrategy类的具体用法?Java RedirectStrategy怎么用?Java RedirectStrategy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RedirectStrategy类属于org.apache.http.client包,在下文中一共展示了RedirectStrategy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DefaultRequestDirector

import org.apache.http.client.RedirectStrategy; //导入依赖的package包/类
@Deprecated
public DefaultRequestDirector(
        final Log log,
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectStrategy redirectStrategy,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    this(LogFactory.getLog(DefaultRequestDirector.class),
            requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler,
            redirectStrategy,
            new AuthenticationStrategyAdaptor(targetAuthHandler),
            new AuthenticationStrategyAdaptor(proxyAuthHandler),
            userTokenHandler,
            params);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:DefaultRequestDirector.java

示例2: TracingHttpClientBuilder

import org.apache.http.client.RedirectStrategy; //导入依赖的package包/类
/**
     * @param redirectStrategy redirect strategy, do not call
     * {@link HttpClientBuilder#disableRedirectHandling()}
     * @param redirectHandlingDisabled disable redirect strategy, do not call
     * {@link org.apache.http.impl.client.HttpClientBuilder#setRedirectStrategy(RedirectStrategy)}
     * @param tracer tracer instance
     * @param spanDecorators decorators
     */
public TracingHttpClientBuilder(
    RedirectStrategy redirectStrategy,
    boolean redirectHandlingDisabled,
    Tracer tracer,
    List<ApacheClientSpanDecorator> spanDecorators) {
    this.redirectStrategy = redirectStrategy;
    this.redirectHandlingDisabled = redirectHandlingDisabled;
    this.tracer = tracer;
    this.spanDecorators = new ArrayList<>(spanDecorators);

    super.setRedirectStrategy(redirectStrategy);
    if (redirectHandlingDisabled) {
        super.disableRedirectHandling();
    }
}
 
开发者ID:opentracing-contrib,项目名称:java-apache-httpclient,代码行数:24,代码来源:TracingHttpClientBuilder.java

示例3: doFollowCrossSiteRedirects

import org.apache.http.client.RedirectStrategy; //导入依赖的package包/类
@Test
public void doFollowCrossSiteRedirects() throws Exception {
  when(response.getStatusLine()).thenReturn(statusLine);

  final RedirectStrategy underTest = new NexusRedirectStrategy();

  // simple cross redirect
  request = new HttpGet("http://hostA/dir");
  when(statusLine.getStatusCode()).thenReturn(SC_MOVED_TEMPORARILY);
  when(response.getFirstHeader(argThat(equalToIgnoringCase(LOCATION))))
      .thenReturn(new BasicHeader(LOCATION, "http://hostB/dir"));
  assertThat(underTest.isRedirected(request, response, new BasicHttpContext()), is(true));

  // cross redirect to dir (failed coz NEXUS-5744)
  request = new HttpGet("http://hostA/dir/");
  when(statusLine.getStatusCode()).thenReturn(SC_MOVED_TEMPORARILY);
  when(response.getFirstHeader(argThat(equalToIgnoringCase(LOCATION))))
      .thenReturn(new BasicHeader(LOCATION, "http://hostB/dir/"));
  assertThat(underTest.isRedirected(request, response, new BasicHttpContext()), is(true));
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:21,代码来源:NexusRedirectStrategyTest.java

示例4: getWithoutAutoRedirect

import org.apache.http.client.RedirectStrategy; //导入依赖的package包/类
/**
 * HTTP GET Without Handling HTTP redirects automatically
 * 
 * @param url
 * @param headers
 * @return CloseableHttpResponse
 */
public static CloseableHttpResponse getWithoutAutoRedirect(String url, Map<String, String> headers) {
	if (url == null) {
		return null;
	}
	HttpGet get = new HttpGet(url);
	addHeaders(get, headers);
	CloseableHttpResponse response = null;
	try {
		client = HttpClients.custom().disableRedirectHandling().build();
		response = visit(get);
		RedirectStrategy rs = DefaultRedirectStrategy.INSTANCE;
		client = HttpClients.custom().setRedirectStrategy(rs).build();
	} catch (Exception e) {
		logger.error(e.getMessage());
		e.printStackTrace();
	}
	return response;
}
 
开发者ID:gitzhou,项目名称:yunti-speed-test,代码行数:26,代码来源:HttpUtils.java

示例5: getRedirectStrategy

import org.apache.http.client.RedirectStrategy; //导入依赖的package包/类
/**
 * @since 4.1
 */
public synchronized final RedirectStrategy getRedirectStrategy() {
    if (redirectStrategy == null) {
        redirectStrategy = new DefaultRedirectStrategy();
    }
    return redirectStrategy;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:AbstractHttpClient.java

示例6: createClientRequestDirector

import org.apache.http.client.RedirectStrategy; //导入依赖的package包/类
/**
 * @deprecated (4.2) do not use
 */
@Deprecated 
protected RequestDirector createClientRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectStrategy redirectStrategy,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    return new DefaultRequestDirector(
            log,
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectStrategy,
            targetAuthHandler,
            proxyAuthHandler,
            userTokenHandler,
            params);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:AbstractHttpClient.java

示例7: TracingClientExec

import org.apache.http.client.RedirectStrategy; //导入依赖的package包/类
public TracingClientExec(
    ClientExecChain clientExecChain,
    RedirectStrategy redirectStrategy,
    boolean redirectHandlingDisabled,
    Tracer tracer,
    List<ApacheClientSpanDecorator> spanDecorators) {
  this.requestExecutor = clientExecChain;
  this.redirectStrategy = redirectStrategy;
  this.redirectHandlingDisabled = redirectHandlingDisabled;
  this.tracer = tracer;
  this.spanDecorators = new ArrayList<>(spanDecorators);
}
 
开发者ID:opentracing-contrib,项目名称:java-apache-httpclient,代码行数:13,代码来源:TracingClientExec.java

示例8: setRedirectStrategy

import org.apache.http.client.RedirectStrategy; //导入依赖的package包/类
private void setRedirectStrategy(HttpClientBuilder httpClientBuilder) {
    RedirectStrategy redirectStrategy = config.getRedirectStrategy().getImplementation();
    if (redirectStrategy == null) {
        httpClientBuilder.disableRedirectHandling();
    } else {
        httpClientBuilder.setRedirectStrategy(redirectStrategy);
    }
}
 
开发者ID:vy,项目名称:hrrs,代码行数:9,代码来源:ApacheHttpClientFactory.java

示例9: RedirectExec

import org.apache.http.client.RedirectStrategy; //导入依赖的package包/类
public RedirectExec(
        final ClientExecChain requestExecutor,
        final HttpRoutePlanner routePlanner,
        final RedirectStrategy redirectStrategy) {
    super();
    Args.notNull(requestExecutor, "HTTP client request executor");
    Args.notNull(routePlanner, "HTTP route planner");
    Args.notNull(redirectStrategy, "HTTP redirect strategy");
    this.requestExecutor = requestExecutor;
    this.routePlanner = routePlanner;
    this.redirectStrategy = redirectStrategy;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:13,代码来源:RedirectExec.java

示例10: createClientRequestDirector

import org.apache.http.client.RedirectStrategy; //导入依赖的package包/类
/**
 * @deprecated (4.2) do not use
 */
@Deprecated
protected RequestDirector createClientRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectStrategy redirectStrategy,
        final AuthenticationHandler targetAuthHandler,
        final AuthenticationHandler proxyAuthHandler,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    return new DefaultRequestDirector(
            log,
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectStrategy,
            targetAuthHandler,
            proxyAuthHandler,
            userTokenHandler,
            params);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:33,代码来源:AbstractHttpClient.java

示例11: doNotFollowRedirectsToDirIndex

import org.apache.http.client.RedirectStrategy; //导入依赖的package包/类
@Test
public void doNotFollowRedirectsToDirIndex() throws Exception {
  when(response.getStatusLine()).thenReturn(statusLine);

  final RedirectStrategy underTest = new NexusRedirectStrategy();
  HttpContext httpContext;

  // no location header
  request = new HttpGet("http://localhost/dir/fileA");
  httpContext = new BasicHttpContext();
  httpContext.setAttribute(CONTENT_RETRIEVAL_MARKER_KEY, Boolean.TRUE);
  when(statusLine.getStatusCode()).thenReturn(SC_OK);
  assertThat(underTest.isRedirected(request, response, httpContext), is(false));

  // redirect to file
  request = new HttpGet("http://localhost/dir/fileA");
  httpContext = new BasicHttpContext();
  httpContext.setAttribute(CONTENT_RETRIEVAL_MARKER_KEY, Boolean.TRUE);
  when(statusLine.getStatusCode()).thenReturn(SC_MOVED_TEMPORARILY);
  when(response.getFirstHeader(argThat(equalToIgnoringCase(LOCATION))))
      .thenReturn(new BasicHeader(LOCATION, "http://localhost/dir/fileB"));
  assertThat(underTest.isRedirected(request, response, httpContext), is(true));

  // redirect to dir
  request = new HttpGet("http://localhost/dir");
  httpContext = new BasicHttpContext();
  httpContext.setAttribute(CONTENT_RETRIEVAL_MARKER_KEY, Boolean.TRUE);
  when(statusLine.getStatusCode()).thenReturn(SC_MOVED_TEMPORARILY);
  when(response.getFirstHeader(argThat(equalToIgnoringCase(LOCATION))))
      .thenReturn(new BasicHeader(LOCATION, "http://localhost/dir/"));
  assertThat(underTest.isRedirected(request, response, httpContext), is(false));
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:33,代码来源:NexusRedirectStrategyTest.java

示例12: createClientRequestDirector

import org.apache.http.client.RedirectStrategy; //导入依赖的package包/类
@Override
protected RequestDirector createClientRequestDirector(HttpRequestExecutor requestExec,
                                                      ClientConnectionManager conman,
                                                      ConnectionReuseStrategy reustrat,
                                                      ConnectionKeepAliveStrategy kastrat,
                                                      HttpRoutePlanner rouplan,
                                                      HttpProcessor httpProcessor,
                                                      HttpRequestRetryHandler retryHandler,
                                                      RedirectStrategy redirectStrategy,
                                                      AuthenticationStrategy targetAuthStrategy,
                                                      AuthenticationStrategy proxyAuthStrategy,
                                                      UserTokenHandler userTokenHandler,
                                                      HttpParams params)
{
  return new RedirectRequestDirector(log,
                                     requestExec,
                                     conman,
                                     reustrat,
                                     kastrat,
                                     rouplan,
                                     httpProcessor,
                                     retryHandler,
                                     redirectStrategy,
                                     targetAuthStrategy,
                                     proxyAuthStrategy,
                                     userTokenHandler,
                                     params);
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:29,代码来源:RedirectHttpClient.java

示例13: RedirectRequestDirector

import org.apache.http.client.RedirectStrategy; //导入依赖的package包/类
public RedirectRequestDirector(Log log,
                               HttpRequestExecutor requestExec,
                               ClientConnectionManager conman,
                               ConnectionReuseStrategy reustrat,
                               ConnectionKeepAliveStrategy kastrat,
                               HttpRoutePlanner rouplan,
                               HttpProcessor httpProcessor,
                               HttpRequestRetryHandler retryHandler,
                               RedirectStrategy redirectStrategy,
                               AuthenticationStrategy targetAuthStrategy,
                               AuthenticationStrategy proxyAuthStrategy,
                               UserTokenHandler userTokenHandler,
                               HttpParams params)
{
  super(log,
        requestExec,
        conman,
        reustrat,
        kastrat,
        rouplan,
        httpProcessor,
        retryHandler,
        redirectStrategy,
        targetAuthStrategy,
        proxyAuthStrategy,
        userTokenHandler,
        params);
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:29,代码来源:RedirectRequestDirector.java

示例14: createRedirectStrategy

import org.apache.http.client.RedirectStrategy; //导入依赖的package包/类
protected RedirectStrategy createRedirectStrategy() {
    return new FormatLocationRedirectStrategy();
}
 
开发者ID:brucezee,项目名称:jspider,代码行数:4,代码来源:HttpClientFactory.java

示例15: getRedirectionStrategy

import org.apache.http.client.RedirectStrategy; //导入依赖的package包/类
public RedirectStrategy getRedirectionStrategy() {
    return this.redirectionStrategy;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:4,代码来源:SimpleHttpClientFactoryBean.java


注:本文中的org.apache.http.client.RedirectStrategy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。