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

SyncHttpClient.java 文件源码 项目:sealtalk-android-master 阅读 72 收藏 0 点赞 0 评论 0
/**
 * 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;
        }
    });
}
AsyncHttpClient.java 文件源码 项目:sealtalk-android-master 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 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;
        }
    });
}
SyncHttpClient.java 文件源码 项目:rongyunDemo 阅读 25 收藏 0 点赞 0 评论 0
/**
 * 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;
        }
    });
}
AsyncHttpClient.java 文件源码 项目:rongyunDemo 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 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;
        }
    });
}
SyncHttpClient.java 文件源码 项目:RongCloudJcenter 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 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;
        }
    });
}
AsyncHttpClient.java 文件源码 项目:RongCloudJcenter 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 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;
        }
    });
}
SyncHttpClient.java 文件源码 项目:RongChat 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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;
        }
    });
}
AsyncHttpClient.java 文件源码 项目:RongChat 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 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;
        }
    });
}
SyncHttpClient.java 文件源码 项目:sealtalk-android 阅读 31 收藏 0 点赞 0 评论 0
/**
 * 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;
        }
    });
}
AsyncHttpClient.java 文件源码 项目:sealtalk-android 阅读 25 收藏 0 点赞 0 评论 0
/**
 * 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;
        }
    });
}
HttpClient.java 文件源码 项目:glvideoplayer-android 阅读 24 收藏 0 点赞 0 评论 0
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);
}
AsyncHttpClient.java 文件源码 项目:skandroid-core 阅读 18 收藏 0 点赞 0 评论 0
/**
 * 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;
        }
    });
}
RequestHelper.java 文件源码 项目:MALFriends 阅读 22 收藏 0 点赞 0 评论 0
@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;
}
AsyncHttpClient.java 文件源码 项目:Libraries-for-Android-Developers 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 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;
        }
    });
}
NetworkConnector.java 文件源码 项目:Giraffe 阅读 20 收藏 0 点赞 0 评论 0
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);
}
UploadService.java 文件源码 项目:dCache-Cloud 阅读 24 收藏 0 点赞 0 评论 0
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;
    }


问题


面经


文章

微信
公众号

扫码关注公众号