本文整理汇总了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);
}
示例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();
}
}
示例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));
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例14: createRedirectStrategy
import org.apache.http.client.RedirectStrategy; //导入依赖的package包/类
protected RedirectStrategy createRedirectStrategy() {
return new FormatLocationRedirectStrategy();
}
示例15: getRedirectionStrategy
import org.apache.http.client.RedirectStrategy; //导入依赖的package包/类
public RedirectStrategy getRedirectionStrategy() {
return this.redirectionStrategy;
}