diff --git a/src/org/sword/lang/HttpUtils.java b/src/org/sword/lang/HttpUtils.java index a6859ff..1d73f39 100644 --- a/src/org/sword/lang/HttpUtils.java +++ b/src/org/sword/lang/HttpUtils.java @@ -17,7 +17,7 @@ import org.sword.lang.http.HttpsUtils; /** - * + * http 工具集 * @author chengn * @date 2014年12月12日 */ @@ -28,7 +28,7 @@ public class HttpUtils { /** * post 请求 - * + * 支持https * @param url * @return */ @@ -37,7 +37,8 @@ public static String post(String url) { } /** - * + * post 请求 带参数 + * 支持https * @param url * @param data * @return @@ -49,7 +50,7 @@ public static String post(String url, String data){ } /** - * + * get请求,支持https * @param url * @return */ @@ -68,9 +69,6 @@ public static String get(String url){ */ private static String HttpPost(String url, String data) { try { -// HttpEntity entity = Request.Post(url) -// .bodyString(data,ContentType.create("text/html", Consts.UTF_8)) -// .execute().returnResponse().getEntity(); HttpClient httpClient = new DefaultHttpClient(); HttpPost post = new HttpPost(url); if(data != null && !data.equals("")){ @@ -95,8 +93,6 @@ private static String HttpPost(String url, String data) { */ private static String httpGet(String url) { try { -// HttpEntity entity = Request.Post(url). -// execute().returnResponse().getEntity(); HttpClient httpClient = new DefaultHttpClient(); HttpGet get = new HttpGet(url); HttpResponse response = httpClient.execute(get); diff --git a/src/org/sword/lang/http/HttpsClient.java b/src/org/sword/lang/http/HttpsClient.java index 09d3bc7..3bc132c 100644 --- a/src/org/sword/lang/http/HttpsClient.java +++ b/src/org/sword/lang/http/HttpsClient.java @@ -1,5 +1,9 @@ + +/** + * + */ package org.sword.lang.http; -import java.security.KeyManagementException; + import java.security.cert.CertificateException; import java.security.cert.X509Certificate; @@ -13,16 +17,18 @@ import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.impl.client.DefaultHttpClient; -/** - * - */ /** + * 支持https的所有站点信任 * @author ChengNing * @date 2015年1月13日 */ public class HttpsClient extends DefaultHttpClient { + /** + * 重写DefaultHttpClient + * @throws Exception + */ public HttpsClient() throws Exception { super(); SSLContext ctx = SSLContext.getInstance("TLS");