Java 类org.apache.http.impl.client.DefaultRedirectHandler 实例源码

项目:sealtalk-android-master    文件:SyncHttpClient.java   
/**
 * Simple interface method, to enable or disable redirects. If you set
 * manually RedirectHandler on underlying HttpClient, effects of this method
 * will be canceled.
 *
 * @param enableRedirects boolean
 */
public void setEnableRedirects(final boolean enableRedirects) {
    httpClient.setRedirectHandler(new DefaultRedirectHandler() {
        @Override
        public boolean isRedirectRequested(HttpResponse response, HttpContext context) {
            return enableRedirects;
        }
    });
}
项目:sealtalk-android-master    文件:AsyncHttpClient.java   
/**
 * Simple interface method, to enable or disable redirects. If you set manually RedirectHandler
 * on underlying HttpClient, effects of this method will be canceled.
 *
 * @param enableRedirects boolean
 */
public void setEnableRedirects(final boolean enableRedirects) {
    httpClient.setRedirectHandler(new DefaultRedirectHandler() {
        @Override
        public boolean isRedirectRequested(HttpResponse response, HttpContext context) {
            return enableRedirects;
        }
    });
}
项目:rongyunDemo    文件:SyncHttpClient.java   
/**
 * Simple interface method, to enable or disable redirects. If you set
 * manually RedirectHandler on underlying HttpClient, effects of this method
 * will be canceled.
 *
 * @param enableRedirects boolean
 */
public void setEnableRedirects(final boolean enableRedirects) {
    httpClient.setRedirectHandler(new DefaultRedirectHandler() {
        @Override
        public boolean isRedirectRequested(HttpResponse response, HttpContext context) {
            return enableRedirects;
        }
    });
}
项目:rongyunDemo    文件:AsyncHttpClient.java   
/**
 * Simple interface method, to enable or disable redirects. If you set manually RedirectHandler
 * on underlying HttpClient, effects of this method will be canceled.
 *
 * @param enableRedirects boolean
 */
public void setEnableRedirects(final boolean enableRedirects) {
    httpClient.setRedirectHandler(new DefaultRedirectHandler() {
        @Override
        public boolean isRedirectRequested(HttpResponse response, HttpContext context) {
            return enableRedirects;
        }
    });
}
项目:RongCloudJcenter    文件:SyncHttpClient.java   
/**
 * Simple interface method, to enable or disable redirects. If you set
 * manually RedirectHandler on underlying HttpClient, effects of this method
 * will be canceled.
 *
 * @param enableRedirects boolean
 */
public void setEnableRedirects(final boolean enableRedirects) {
    httpClient.setRedirectHandler(new DefaultRedirectHandler() {
        @Override
        public boolean isRedirectRequested(HttpResponse response, HttpContext context) {
            return enableRedirects;
        }
    });
}
项目:RongCloudJcenter    文件:AsyncHttpClient.java   
/**
 * Simple interface method, to enable or disable redirects. If you set manually RedirectHandler
 * on underlying HttpClient, effects of this method will be canceled.
 *
 * @param enableRedirects boolean
 */
public void setEnableRedirects(final boolean enableRedirects) {
    httpClient.setRedirectHandler(new DefaultRedirectHandler() {
        @Override
        public boolean isRedirectRequested(HttpResponse response, HttpContext context) {
            return enableRedirects;
        }
    });
}
项目:RongChat    文件:SyncHttpClient.java   
/**
 * Simple interface method, to enable or disable redirects. If you set
 * manually RedirectHandler on underlying HttpClient, effects of this method
 * will be canceled.
 * 
 * @param enableRedirects
 *            boolean
 */
public void setEnableRedirects(final boolean enableRedirects) {
    httpClient.setRedirectHandler(new DefaultRedirectHandler() {
        @Override
        public boolean isRedirectRequested(HttpResponse response, HttpContext context) {
            return enableRedirects;
        }
    });
}
项目:RongChat    文件:AsyncHttpClient.java   
/**
 * Simple interface method, to enable or disable redirects. If you set manually RedirectHandler
 * on underlying HttpClient, effects of this method will be canceled.
 *
 * @param enableRedirects boolean
 */
public void setEnableRedirects(final boolean enableRedirects) {
    httpClient.setRedirectHandler(new DefaultRedirectHandler() {
        @Override
        public boolean isRedirectRequested(HttpResponse response, HttpContext context) {
            return enableRedirects;
        }
    });
}
项目:sealtalk-android    文件:SyncHttpClient.java   
/**
 * Simple interface method, to enable or disable redirects. If you set
 * manually RedirectHandler on underlying HttpClient, effects of this method
 * will be canceled.
 *
 * @param enableRedirects boolean
 */
public void setEnableRedirects(final boolean enableRedirects) {
    httpClient.setRedirectHandler(new DefaultRedirectHandler() {
        @Override
        public boolean isRedirectRequested(HttpResponse response, HttpContext context) {
            return enableRedirects;
        }
    });
}
项目:sealtalk-android    文件:AsyncHttpClient.java   
/**
 * Simple interface method, to enable or disable redirects. If you set manually RedirectHandler
 * on underlying HttpClient, effects of this method will be canceled.
 *
 * @param enableRedirects boolean
 */
public void setEnableRedirects(final boolean enableRedirects) {
    httpClient.setRedirectHandler(new DefaultRedirectHandler() {
        @Override
        public boolean isRedirectRequested(HttpResponse response, HttpContext context) {
            return enableRedirects;
        }
    });
}
项目:glvideoplayer-android    文件:HttpClient.java   
private void init(String ua) {
    client = new DefaultHttpClient();

    client.setRedirectHandler(new DefaultRedirectHandler() {
        public URI getLocationURI(HttpResponse res, HttpContext arg1) throws ProtocolException {
            URI uri = super.getLocationURI(res, arg1);
            if (res.getFirstHeader("Location") != null) {
                location = uri.toString();// res.getFirstHeader("Location").getValue();
            }
            return uri;
        }
    });
    client.getParams().setParameter("http.useragent", ua);
}
项目:skandroid-core    文件:AsyncHttpClient.java   
/**
 * Simple interface method, to enable or disable redirects. If you set manually RedirectHandler
 * on underlying HttpClient, effects of this method will be canceled.
 *
 * @param enableRedirects boolean
 */
public void setEnableRedirects(final boolean enableRedirects) {
    httpClient.setRedirectHandler(new DefaultRedirectHandler() {
        @Override
        public boolean isRedirectRequested(HttpResponse response, HttpContext context) {
            return enableRedirects;
        }
    });
}
项目:MALFriends    文件:RequestHelper.java   
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
private static RequestQueue getRequestQueue() {
    if (mRequestQueue == null) {
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
            DefaultHttpClient httpClient = new DefaultHttpClient();
            httpClient.setRedirectHandler(new DefaultRedirectHandler() {
                @Override
                public boolean isRedirectRequested(HttpResponse response,
                        HttpContext context) {
                    boolean isRedirect = super.isRedirectRequested(
                            response, context);
                    if (!isRedirect) {
                        int responseCode = response.getStatusLine()
                                .getStatusCode();
                        if (responseCode == 301 || responseCode == 302) {
                            return true;
                        }
                    }
                    return isRedirect;
                }
            });
            httpClient.setCookieStore(new BasicCookieStore());
            HttpStack httpStack = new HttpClientStack(httpClient);
            mRequestQueue = Volley.newRequestQueue(MALFriends.getInstance()
                    .getApplicationContext(), httpStack);
        } else {
            HttpURLConnection.setFollowRedirects(true);
            CookieManager manager = new CookieManager(null,
                    CookiePolicy.ACCEPT_ALL);
            CookieHandler.setDefault(manager);
            mRequestQueue = Volley.newRequestQueue(MALFriends.getInstance()
                    .getApplicationContext());
        }

    }
    return mRequestQueue;
}
项目:Libraries-for-Android-Developers    文件:AsyncHttpClient.java   
/**
 * Simple interface method, to enable or disable redirects. If you set manually RedirectHandler
 * on underlying HttpClient, effects of this method will be canceled.
 *
 * @param enableRedirects boolean
 */
public void setEnableRedirects(final boolean enableRedirects) {
    httpClient.setRedirectHandler(new DefaultRedirectHandler() {
        @Override
        public boolean isRedirectRequested(HttpResponse response, HttpContext context) {
            return enableRedirects;
        }
    });
}
项目:Giraffe    文件:NetworkConnector.java   
public void recreate(){
    mHttpClient = getHttpClient();
    mHttpClient.setRedirectHandler(new DefaultRedirectHandler() {
        @Override
        public boolean isRedirectRequested(HttpResponse response, HttpContext context) {
            return false;
        }
    });

    // Proxy settings
    // HttpHost proxy = new HttpHost("192.168.1.103", 8888);
    // mHttpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,proxy);
}
项目:dCache-Cloud    文件:UploadService.java   
private boolean InitializeComponents(Intent intent)
    {
        cr = getContentResolver();
        context = new BasicHttpContext();

        if (android.os.Build.VERSION.SDK_INT >= 11) {
            mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        }

        /* Get Settings Begin */
        SharedPreferences preferences = getSharedPreferences("de.desy.dCacheCloud_preferences", Context.MODE_PRIVATE);
        target.add(preferences.getString("webdav_url", null));
        String user = preferences.getString("webdav_user", null);
        String password = preferences.getString("webdav_password", null);
        /* Get Settings End */

        /*
        if (target.get(target.size()-1) == null) {
            Log.d("dCache", "No URL set up.");
            return false;
        }
        */

        // Get Extras from Intend-Loader

        fileUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);

        File sdCard = Environment.getExternalStorageDirectory();
        fileUri = Uri.parse(String.format("file://%s/%s/%s", sdCard.getAbsolutePath(), "dCacheCloud/.enc", fileUri.getLastPathSegment()));
//      File fileOutput = new File(sdCard, String.format("dCacheCloud/%s", CryptoHelper.hash(fileUri.getLastPathSegment())));

        Log.d("davsync", "Uploading " + fileUri.toString());
        filename = fileUri.getLastPathSegment();



        if (filename == null) {
            Log.d("dCache", "fileName returned null");
            return false;
        }
        setFileHandling();

        try {
            httpClient = ServerHelper.getClient();
        } catch (GeneralSecurityException e) {
            Log.d("SECURITY", String.format("General Security Error: %s", e.toString()));
            e.printStackTrace();
        } catch (IOException e1) {
            Log.d("Unknown", String.format("Error: %s", e1.toString()));
            e1.printStackTrace();
        }

        httpClient.setRedirectHandler(new DefaultRedirectHandler() {    
            @Override
            public URI getLocationURI(HttpResponse response, HttpContext contet) throws org.apache.http.ProtocolException {

                Log.d("Rederection!!: ", Arrays.toString(response.getHeaders("Location")));
                System.out.println(Arrays.toString(response.getHeaders("Location")));

                target.add(Arrays.toString(response.getHeaders("Location")));
                isRedirected = true;
                return super.getLocationURI(response, context);
            }

        });

        httpPut = new HttpPut();
        httpPut.setEntity(entity);
        ServerHelper.setCredentials(httpClient, httpPut, user, password);

        return true;
    }