Compare commits

..

1 Commits

  1. 6
      src/main/java/com/fanruan/api/design/work/ConnectionComboBoxPanel.java
  2. 23
      src/main/java/com/fanruan/api/net/http/HttpKit.java

6
src/main/java/com/fanruan/api/design/work/ConnectionComboBoxPanel.java

@ -130,11 +130,7 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel {
ConfigurationKit.modify(ConnectionConfig.class, new Runner() { ConfigurationKit.modify(ConnectionConfig.class, new Runner() {
@Override @Override
public void run() { public void run() {
try { connectionListPane.update(connectionConfig);
connectionListPane.update(connectionConfig);
} catch (Exception e) {
throw new RuntimeException(e);
}
} }
}, new WorkerCallBack() { }, new WorkerCallBack() {
@Override @Override

23
src/main/java/com/fanruan/api/net/http/HttpKit.java

@ -44,7 +44,6 @@ import java.net.URISyntaxException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import static com.fanruan.api.net.http.rs.HttpRequestType.POST; import static com.fanruan.api.net.http.rs.HttpRequestType.POST;
@ -194,12 +193,12 @@ public class HttpKit {
/** /**
* 发起POST JSON请求并获取返回的文本 * 发起POST JSON请求并获取返回的文本
* 以前版本只支持jsonObject 修改为object就可以支持多种json格式 *
* @param url 响应请求的的服务器地址 * @param url 响应请求的的服务器地址
* @param params POST请求的参数 * @param params POST请求的参数
* @return 服务器返回的文本内容 * @return 服务器返回的文本内容
*/ */
public static String postJSON(String url, Object params, Map<String, String> headers) throws IOException { public static String postJSON(String url, JSONObject params, Map<String, String> headers) throws IOException {
StringEntity jsonEntity = new StringEntity(params.toString(), "UTF-8"); StringEntity jsonEntity = new StringEntity(params.toString(), "UTF-8");
jsonEntity.setContentEncoding("UTF-8"); jsonEntity.setContentEncoding("UTF-8");
if (headers != null) { if (headers != null) {
@ -485,8 +484,8 @@ public class HttpKit {
* @param file 要上传的文件默认的文件编码为utf-8 * @param file 要上传的文件默认的文件编码为utf-8
* @throws IOException 上传中出现错误则抛出此异常 * @throws IOException 上传中出现错误则抛出此异常
*/ */
public static String upload(String url, File file) throws IOException { public static void upload(String url, File file) throws IOException {
return upload(url, file, StandardCharsets.UTF_8); upload(url, file, Charset.forName("utf-8"));
} }
/** /**
@ -497,8 +496,8 @@ public class HttpKit {
* @param charset 文件的编码 * @param charset 文件的编码
* @throws IOException 上传中出现错误则抛出此异常 * @throws IOException 上传中出现错误则抛出此异常
*/ */
public static String upload(String url, File file, Charset charset) throws IOException { public static void upload(String url, File file, Charset charset) throws IOException {
return upload(url, new FileEntity(file), charset); upload(url, new FileEntity(file), charset);
} }
/** /**
@ -521,8 +520,8 @@ public class HttpKit {
* @param charset 文件的编码 * @param charset 文件的编码
* @throws IOException 上传中出现错误则抛出此异常 * @throws IOException 上传中出现错误则抛出此异常
*/ */
public static String upload(String url, FileEntity fileEntity, Charset charset) throws IOException { public static void upload(String url, FileEntity fileEntity, Charset charset) throws IOException {
return upload(url, fileEntity, charset, Collections.<String, String>emptyMap(), POST); upload(url, fileEntity, charset, Collections.<String, String>emptyMap(), POST);
} }
/** /**
@ -552,8 +551,8 @@ public class HttpKit {
* @param httpRequestType 请求类型 * @param httpRequestType 请求类型
* @throws IOException 上传中出现错误则抛出此异常 * @throws IOException 上传中出现错误则抛出此异常
*/ */
public static String upload(String url, HttpEntity reqEntity, Charset charset, Map<String, String> headers, HttpRequestType httpRequestType) throws IOException { public static void upload(String url, HttpEntity reqEntity, Charset charset, Map<String, String> headers, HttpRequestType httpRequestType) throws IOException {
return executeAndParse(HttpRequest executeAndParse(HttpRequest
.custom() .custom()
.url(url) .url(url)
.headers(headers) .headers(headers)
@ -561,7 +560,7 @@ public class HttpKit {
.httpEntity(reqEntity) .httpEntity(reqEntity)
.encoding(charset.toString()) .encoding(charset.toString())
.build(), .build(),
new TextResponseHandle(charset.toString())); UploadResponseHandle.DEFAULT);
} }
/** /**

Loading…
Cancel
Save