feat: 优化API 修复http模块错误
This commit is contained in:
@ -47,7 +47,7 @@ function open(url, method, header) {
|
||||
var conn = new URL(url).openConnection();
|
||||
if (conn instanceof HttpsURLConnection) {
|
||||
conn.setHostnameVerifier(TrustAnyHostnameVerifier);
|
||||
conn.setSSLSocketFactory(TrustAnyHostnameVerifier);
|
||||
conn.setSSLSocketFactory(SSLSocketFactory);
|
||||
}
|
||||
conn.setRequestMethod(method);
|
||||
conn.setDoOutput(true);
|
||||
@ -81,10 +81,12 @@ function request(url, method, header, params, body) {
|
||||
var conn = open(buildUrl(url, params), method, header);
|
||||
try {
|
||||
conn.connect();
|
||||
var out = conn.getOutputStream();
|
||||
out.write(new String(body).getBytes(config.Charset));
|
||||
out.flush();
|
||||
out.close();
|
||||
if (body) {
|
||||
var out = conn.getOutputStream();
|
||||
out.write(new String(body).getBytes(config.Charset));
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
return response(conn);
|
||||
} finally {
|
||||
conn.disconnect();
|
||||
@ -110,4 +112,4 @@ var http = {
|
||||
}
|
||||
})
|
||||
|
||||
exports = module.exports = http;
|
||||
exports = module.exports = http;
|
||||
|
Reference in New Issue
Block a user