DefaultHttpClient client = new DefaultHttpClient(); client.setRedirectStrategy(new LaxRedirectStrategy());
DefaultHttpClient client = new DefaultHttpClient() client.setRedirectStrategy(new LaxRedirectStrategy())
/** * Provides the HttpClient implementation. * * @param httpParams * Parameters for the HttpClient. If {@code null}, defaults are used. * @param connectionManager * The connection manager for the HttpClient. If {@code null}, the default is used. * @return the {@link HttpClient} instance */ @Provides protected HttpClient provideHttpClient(final HttpParams httpParams, final ClientConnectionManager connectionManager, final RedirectStrategy redirectStrategy) { DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager, httpParams); httpClient.setRedirectStrategy(redirectStrategy); return httpClient; }
/** * Provides the HttpClient implementation. * * @param httpParams * Parameters for the HttpClient. If {@code null}, defaults are used. * @param connectionManager * The connection manager for the HttpClient. If {@code null}, the default is used. * @return the {@link HttpClient} instance */ @Provides protected HttpClient provideHttpClient(final HttpParams httpParams, final ClientConnectionManager connectionManager, final RedirectStrategy redirectStrategy) { DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager, httpParams); httpClient.setRedirectStrategy(redirectStrategy); return httpClient; }
public void disableRedirection() { http.setRedirectStrategy( new DefaultRedirectStrategy() { @Override public boolean isRedirected( final HttpRequest request, final HttpResponse response, final HttpContext context ) throws ProtocolException { return false; } } ); }
public static Deque<URI> expand(String uri) { try { HttpHead head = new HttpHead(uri); SpyStrategy spy = new SpyStrategy(head.getURI()); DefaultHttpClient client = new DefaultHttpClient(); client.setRedirectStrategy(spy); // FIXME: the following completely ignores HTTP errors: client.execute(head); return spy.history; } catch (IOException e) { throw new RuntimeException(e); } }
public static DefaultHttpClient getClient() { DefaultHttpClient client = new DefaultHttpClient(); client.setRedirectStrategy(new MyRedirectHandler()); return client; }
DefaultHttpClient client = new DefaultHttpClient(); client.setRedirectStrategy(new LaxRedirectStrategy());
public void enableRedirection() { http.setRedirectStrategy( new DefaultRedirectStrategy() ); }
DefaultHttpClient httpClient = new DefaultHttpClient(); httpClient.setRedirectStrategy(new LaxRedirectStrategy()); httpClient.execute(request);
DefaultHttpClient httpclient = new DefaultHttpClient(); DefaultRedirectStrategy redirect = new Redirect() { public boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context) { boolean isRedirect = false; try { isRedirect = super.isRedirected(request, response, context); } catch (ProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (!isRedirect) { int responseCode = response.getStatusLine().getStatusCode(); if (responseCode == 301 || responseCode == 302) { return true; } } return isRedirect; } }; httpclient.setRedirectStrategy(redirect);
/** * Configures the fresh instance of HttpClient for given proxy repository specific needs. Right now it sets * appropriate redirect strategy only. * * @param proxyRepository * @param ctx */ protected void configure( final ProxyRepository proxyRepository, final RemoteStorageContext ctx, final DefaultHttpClient httpClient ) { // set UA httpClient.getParams().setParameter( HttpProtocolParams.USER_AGENT, userAgentBuilder.formatRemoteRepositoryStorageUserAgentString( proxyRepository, ctx ) ); // set redirect strategy httpClient.setRedirectStrategy( getProxyRepositoryRedirectStrategy( proxyRepository, ctx ) ); }
c = new DefaultHttpClient(params); if (followRedirects) c.setRedirectStrategy(redirectStrategy); HttpResponse resp = null; try {
httpclient.setRedirectStrategy(new DefaultRedirectStrategy() { public boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context) { boolean isRedirect=false;
httpClient.setRedirectStrategy(new LaxRedirectStrategy());
client.setRedirectStrategy(new LMFRedirectStrategy()); client.setHttpRequestRetryHandler(new LMFHttpRequestRetryHandler()); idleConnectionMonitorThread = new IdleConnectionMonitorThread(client.getConnectionManager());
client.setRedirectStrategy(new DefaultRedirectStrategy() { @Override protected boolean isRedirectable(String method) {
client.setRedirectStrategy(new DefaultRedirectStrategy() { @Override protected boolean isRedirectable(String method) {
hc.setRedirectStrategy(new LMFRedirectStrategy()); hc.setHttpRequestRetryHandler(new LMFHttpRequestRetryHandler()); hc.removeRequestInterceptorByClass(org.apache.http.protocol.RequestUserAgent.class);
hc.setRedirectStrategy(new LMFRedirectStrategy()); hc.setHttpRequestRetryHandler(new LMFHttpRequestRetryHandler()); hc.removeRequestInterceptorByClass(org.apache.http.protocol.RequestUserAgent.class);