Skip to content

Commit

Permalink
添加注释
Browse files Browse the repository at this point in the history
  • Loading branch information
chengn committed Jan 13, 2015
1 parent 48dc506 commit 514c1b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
14 changes: 5 additions & 9 deletions src/org/sword/lang/HttpUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.sword.lang.http.HttpsUtils;

/**
*
* http 工具集
* @author chengn
* @date 2014年12月12日
*/
Expand All @@ -28,7 +28,7 @@ public class HttpUtils {

/**
* post 请求
*
* 支持https
* @param url
* @return
*/
Expand All @@ -37,7 +37,8 @@ public static String post(String url) {
}

/**
*
* post 请求 带参数
* 支持https
* @param url
* @param data
* @return
Expand All @@ -49,7 +50,7 @@ public static String post(String url, String data){
}

/**
*
* get请求,支持https
* @param url
* @return
*/
Expand All @@ -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("")){
Expand All @@ -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);
Expand Down
14 changes: 10 additions & 4 deletions src/org/sword/lang/http/HttpsClient.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@

/**
*
*/
package org.sword.lang.http;
import java.security.KeyManagementException;

import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

Expand All @@ -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");
Expand Down

0 comments on commit 514c1b5

Please sign in to comment.