You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					
					
						
							61 lines
						
					
					
						
							2.3 KiB
						
					
					
				
			
		
		
	
	
							61 lines
						
					
					
						
							2.3 KiB
						
					
					
				| //package com.ynxbd.common.config.http;
 | |
| //
 | |
| //import org.apache.http.client.HttpClient;
 | |
| //import org.apache.http.client.methods.HttpGet;
 | |
| //import org.apache.http.client.methods.HttpPost;
 | |
| //import org.apache.http.conn.ClientConnectionManager;
 | |
| //import org.apache.http.conn.scheme.Scheme;
 | |
| //import org.apache.http.conn.scheme.SchemeRegistry;
 | |
| //import org.apache.http.impl.client.DefaultHttpClient;
 | |
| //
 | |
| //
 | |
| //public class HttpClientConnectionManager {
 | |
| //
 | |
| //    /**
 | |
| //     * 获取SSL验证的HttpClient
 | |
| //     *
 | |
| //     * @param httpClient
 | |
| //     * @return
 | |
| //     */
 | |
| //    public static HttpClient getSSLInstance(HttpClient httpClient) {
 | |
| //        ClientConnectionManager ccm = httpClient.getConnectionManager();
 | |
| //        SchemeRegistry sr = ccm.getSchemeRegistry();
 | |
| //        sr.register(new Scheme("https", MySSLSocketFactory.getInstance(), 443));
 | |
| //        httpClient = new DefaultHttpClient(ccm, httpClient.getParams());
 | |
| //        return httpClient;
 | |
| //    }
 | |
| //
 | |
| //    /**
 | |
| //     * 模拟浏览器post提交
 | |
| //     *
 | |
| //     * @param url
 | |
| //     * @return
 | |
| //     */
 | |
| //    public static HttpPost getPostMethod(String url) {
 | |
| //        HttpPost method = new HttpPost(url); // 设置响应头信息
 | |
| //        method.addHeader("Connection", "keep-alive");
 | |
| //        method.addHeader("Accept", "*/*");
 | |
| //        method.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
 | |
| //        method.addHeader("Host", "api.mch.weixin.qq.com");
 | |
| //        method.addHeader("X-Requested-With", "XMLHttpRequest");
 | |
| //        method.addHeader("Cache-Control", "max-age=0");
 | |
| //        method.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) ");
 | |
| //        return method;
 | |
| //    }
 | |
| //
 | |
| //    /**
 | |
| //     * 模拟浏览器GET提交
 | |
| //     *
 | |
| //     * @param url
 | |
| //     * @return
 | |
| //     */
 | |
| //    public static HttpGet getGetMethod(String url) {
 | |
| //        HttpGet method = new HttpGet(url);
 | |
| //        // 设置响应头信息
 | |
| //        method.addHeader("Connection", "keep-alive");
 | |
| //        method.addHeader("Cache-Control", "max-age=0");
 | |
| //        method.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) ");
 | |
| //        method.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/;q=0.8");
 | |
| //        return method;
 | |
| //    }
 | |
| //}
 | |
| 
 |