This commit is contained in:
Looly
2022-07-16 22:46:31 +08:00
parent 8e7d09cfc0
commit 681535c575
30 changed files with 1296 additions and 45 deletions

View File

@@ -72,6 +72,7 @@ public class HttpResponse extends HttpBase<HttpResponse> implements Closeable {
* @param isIgnoreBody 是否忽略读取响应体
* @since 3.1.2
*/
@SuppressWarnings("resource")
protected HttpResponse(final HttpConnection httpConnection, final HttpConfig config, final Charset charset, final boolean isAsync, final boolean isIgnoreBody) {
this.httpConnection = httpConnection;
this.config = config;
@@ -249,6 +250,7 @@ public class HttpResponse extends HttpBase<HttpResponse> implements Closeable {
*
* @return byte[]
*/
@SuppressWarnings("resource")
@Override
public byte[] bodyBytes() {
sync();
@@ -403,6 +405,7 @@ public class HttpResponse extends HttpBase<HttpResponse> implements Closeable {
* @param bodyBytes 主体
* @return this
*/
@SuppressWarnings("resource")
public HttpResponse body(final byte[] bodyBytes) {
sync();
if (null != bodyBytes) {
@@ -479,6 +482,7 @@ public class HttpResponse extends HttpBase<HttpResponse> implements Closeable {
* @return this
* @throws HttpException IO异常
*/
@SuppressWarnings("resource")
private HttpResponse initWithDisconnect() throws HttpException {
try {
init();

View File

@@ -51,7 +51,7 @@ public class HttpUtil {
* @return 是否https
*/
public static boolean isHttps(final String url) {
return url.toLowerCase().startsWith("https:");
return StrUtil.startWithIgnoreCase(url, "https:");
}
/**
@@ -62,7 +62,7 @@ public class HttpUtil {
* @since 5.3.8
*/
public static boolean isHttp(final String url) {
return url.toLowerCase().startsWith("http:");
return StrUtil.startWithIgnoreCase(url, "http:");
}
/**
@@ -118,6 +118,7 @@ public class HttpUtil {
* @param customCharset 自定义请求字符集,如果字符集获取不到,使用此字符集
* @return 返回内容,如果只检查状态码,正常只返回 "",不正常返回 null
*/
@SuppressWarnings("resource")
public static String get(final String urlString, final Charset customCharset) {
return HttpRequest.get(urlString).charset(customCharset).execute().body();
}
@@ -140,6 +141,7 @@ public class HttpUtil {
* @return 返回内容,如果只检查状态码,正常只返回 "",不正常返回 null
* @since 3.2.0
*/
@SuppressWarnings("resource")
public static String get(final String urlString, final int timeout) {
return HttpRequest.get(urlString).timeout(timeout).execute().body();
}
@@ -151,6 +153,7 @@ public class HttpUtil {
* @param paramMap post表单数据
* @return 返回数据
*/
@SuppressWarnings("resource")
public static String get(final String urlString, final Map<String, Object> paramMap) {
return HttpRequest.get(urlString).form(paramMap).execute().body();
}
@@ -164,6 +167,7 @@ public class HttpUtil {
* @return 返回数据
* @since 3.3.0
*/
@SuppressWarnings("resource")
public static String get(final String urlString, final Map<String, Object> paramMap, final int timeout) {
return HttpRequest.get(urlString).form(paramMap).timeout(timeout).execute().body();
}
@@ -188,6 +192,7 @@ public class HttpUtil {
* @return 返回数据
* @since 3.2.0
*/
@SuppressWarnings("resource")
public static String post(final String urlString, final Map<String, Object> paramMap, final int timeout) {
return HttpRequest.post(urlString).form(paramMap).timeout(timeout).execute().body();
}
@@ -224,6 +229,7 @@ public class HttpUtil {
* @return 返回数据
* @since 3.2.0
*/
@SuppressWarnings("resource")
public static String post(final String urlString, final String body, final int timeout) {
return HttpRequest.post(urlString).timeout(timeout).body(body).execute().body();
}