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


Java DefaultRedirectHandler类代码示例

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


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

示例1: getRequestQueue

import org.apache.http.impl.client.DefaultRedirectHandler; //导入依赖的package包/类
@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;
}
 
开发者ID:DandreX,项目名称:MALFriends,代码行数:38,代码来源:RequestHelper.java

示例2: setEnableRedirects

import org.apache.http.impl.client.DefaultRedirectHandler; //导入依赖的package包/类
/**
 * 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;
        }
    });
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:16,代码来源:SyncHttpClient.java

示例3: setEnableRedirects

import org.apache.http.impl.client.DefaultRedirectHandler; //导入依赖的package包/类
/**
 * 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;
        }
    });
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:15,代码来源:AsyncHttpClient.java

示例4: setEnableRedirects

import org.apache.http.impl.client.DefaultRedirectHandler; //导入依赖的package包/类
/**
 * 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;
		}
	});
}
 
开发者ID:13120241790,项目名称:RongChat,代码行数:17,代码来源:SyncHttpClient.java

示例5: init

import org.apache.http.impl.client.DefaultRedirectHandler; //导入依赖的package包/类
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);
}
 
开发者ID:binzume,项目名称:glvideoplayer-android,代码行数:15,代码来源:HttpClient.java

示例6: recreate

import org.apache.http.impl.client.DefaultRedirectHandler; //导入依赖的package包/类
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);
}
 
开发者ID:NevRA,项目名称:Giraffe,代码行数:14,代码来源:NetworkConnector.java

示例7: InitializeComponents

import org.apache.http.impl.client.DefaultRedirectHandler; //导入依赖的package包/类
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;
	}
 
开发者ID:To0x,项目名称:dCache-Cloud,代码行数:73,代码来源:UploadService.java


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