This commit is contained in:
zlzw 2024-10-26 01:43:19 +08:00
parent 3f88a20557
commit bc9f82cc8d
3 changed files with 19 additions and 7 deletions

View File

@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ToolsApplication {
public static final String version="1.5.1";
public static final String version="1.5.2";
public static void main(String[] args) {
System.out.println("当前版本号:" + version);

View File

@ -18,9 +18,19 @@ public class HttpTools {
private static final int HttpRequestIndex = 3;
public static String get(String url) {
return https_get(url, null);
if(url.startsWith("http:")){
return https_get(HttpURLConnection.class, url, null);
}else {
return https_get(HttpsURLConnection.class,url, null);
}
}
public static <T extends URLConnection> String https_get(String url, Map<String, String> header) {
if(url.startsWith("http:")){
return https_get(HttpURLConnection.class, url, header);
}else {
return https_get(HttpsURLConnection.class,url, header);
}
}
public static String post(final String url, final byte[] body) {
return http_post(url, body, 0, null);
}
@ -29,10 +39,9 @@ public class HttpTools {
return new HttpTools().http_syncDownload(url, saveName);
}
public static String https_get(String url, Map<String, String> header) {
public static <T extends URLConnection> String https_get(Class<T> c, String url, Map<String, String> header) {
try {
URLConnection connection;
connection = new URL(url).openConnection();
T connection = (T) new URL(url).openConnection();
connection.setConnectTimeout(60*1000);
connection.setReadTimeout(60*1000);
connection.setRequestProperty("User-Agent", getExtUa());

View File

@ -3,6 +3,9 @@ package com.yutou.tools.utils;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.interfaces.DownloadInterface;
import com.yutou.tools.mybatis.dao.ToolsPasswordDao;
import com.yutou.tools.mybatis.model.ToolsPassword;
import com.yutou.tools.mybatis.model.ToolsPasswordExample;
import com.yutou.tools.nas.UpdateIp;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.config.BeanDefinition;
@ -490,6 +493,6 @@ public class Tools {
}
public static void main(String[] args) {
System.out.println(getPinYin("你好"));
System.out.println(getPinYin("webdav"));
}
}