mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -279,9 +279,9 @@ public class HttpUtil {
|
||||
*
|
||||
* @param url 请求的url
|
||||
* @param dest 目标文件或目录,当为目录时,取URL中的文件名,取不到使用编码后的URL做为文件名
|
||||
* @return 文件大小
|
||||
* @return 文件
|
||||
*/
|
||||
public static long downloadFile(final String url, final String dest) {
|
||||
public static File downloadFile(final String url, final String dest) {
|
||||
return downloadFile(url, FileUtil.file(dest));
|
||||
}
|
||||
|
||||
@@ -290,9 +290,9 @@ public class HttpUtil {
|
||||
*
|
||||
* @param url 请求的url
|
||||
* @param destFile 目标文件或目录,当为目录时,取URL中的文件名,取不到使用编码后的URL做为文件名
|
||||
* @return 文件大小
|
||||
* @return 文件
|
||||
*/
|
||||
public static long downloadFile(final String url, final File destFile) {
|
||||
public static File downloadFile(final String url, final File destFile) {
|
||||
return downloadFile(url, destFile, null);
|
||||
}
|
||||
|
||||
@@ -302,10 +302,10 @@ public class HttpUtil {
|
||||
* @param url 请求的url
|
||||
* @param destFile 目标文件或目录,当为目录时,取URL中的文件名,取不到使用编码后的URL做为文件名
|
||||
* @param timeout 超时,单位毫秒,-1表示默认超时
|
||||
* @return 文件大小
|
||||
* @return 文件
|
||||
* @since 4.0.4
|
||||
*/
|
||||
public static long downloadFile(final String url, final File destFile, final int timeout) {
|
||||
public static File downloadFile(final String url, final File destFile, final int timeout) {
|
||||
return downloadFile(url, destFile, timeout, null);
|
||||
}
|
||||
|
||||
@@ -315,9 +315,9 @@ public class HttpUtil {
|
||||
* @param url 请求的url
|
||||
* @param destFile 目标文件或目录,当为目录时,取URL中的文件名,取不到使用编码后的URL做为文件名
|
||||
* @param streamProgress 进度条
|
||||
* @return 文件大小
|
||||
* @return 文件
|
||||
*/
|
||||
public static long downloadFile(final String url, final File destFile, final StreamProgress streamProgress) {
|
||||
public static File downloadFile(final String url, final File destFile, final StreamProgress streamProgress) {
|
||||
return downloadFile(url, destFile, -1, streamProgress);
|
||||
}
|
||||
|
||||
@@ -328,10 +328,10 @@ public class HttpUtil {
|
||||
* @param destFile 目标文件或目录,当为目录时,取URL中的文件名,取不到使用编码后的URL做为文件名
|
||||
* @param timeout 超时,单位毫秒,-1表示默认超时
|
||||
* @param streamProgress 进度条
|
||||
* @return 文件大小
|
||||
* @return 文件
|
||||
* @since 4.0.4
|
||||
*/
|
||||
public static long downloadFile(final String url, final File destFile, final int timeout, final StreamProgress streamProgress) {
|
||||
public static File downloadFile(final String url, final File destFile, final int timeout, final StreamProgress streamProgress) {
|
||||
return HttpDownloader.downloadFile(url, destFile, timeout, streamProgress);
|
||||
}
|
||||
|
||||
@@ -473,8 +473,8 @@ public class HttpUtil {
|
||||
* key1=v1&key2=&key3=v3
|
||||
* </pre>
|
||||
*
|
||||
* @param paramMap 表单数据
|
||||
* @param charset 编码,null表示不encode键值对
|
||||
* @param paramMap 表单数据
|
||||
* @param charset 编码,null表示不encode键值对
|
||||
* @param isFormUrlEncoded 是否为x-www-form-urlencoded模式,此模式下空格会编码为'+'
|
||||
* @return url参数
|
||||
* @since 5.7.16
|
||||
@@ -534,7 +534,7 @@ public class HttpUtil {
|
||||
* @since 4.5.2
|
||||
*/
|
||||
public static String normalizeParams(final String paramPart, final Charset charset) {
|
||||
if(StrUtil.isEmpty(paramPart)){
|
||||
if (StrUtil.isEmpty(paramPart)) {
|
||||
return paramPart;
|
||||
}
|
||||
final StringBuilder builder = new StringBuilder(paramPart.length() + 16);
|
||||
|
@@ -17,6 +17,7 @@ import java.nio.charset.Charset;
|
||||
* @author looly
|
||||
* @since 5.6.4
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
public class HttpDownloader {
|
||||
|
||||
/**
|
||||
@@ -50,10 +51,10 @@ public class HttpDownloader {
|
||||
* @param targetFileOrDir 目标文件或目录,当为目录时,取URL中的文件名,取不到使用编码后的URL做为文件名
|
||||
* @param timeout 超时,单位毫秒,-1表示默认超时
|
||||
* @param streamProgress 进度条
|
||||
* @return 文件大小
|
||||
* @return 文件
|
||||
*/
|
||||
public static long downloadFile(final String url, final File targetFileOrDir, final int timeout, final StreamProgress streamProgress) {
|
||||
return requestDownload(url, timeout).writeBody(targetFileOrDir, streamProgress);
|
||||
public static File downloadFile(final String url, final File targetFileOrDir, final int timeout, final StreamProgress streamProgress) {
|
||||
return requestDownload(url, timeout).body().write(targetFileOrDir, streamProgress);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,11 +67,11 @@ public class HttpDownloader {
|
||||
* @param tempFileSuffix 临时文件后缀,默认".temp"
|
||||
* @param timeout 超时,单位毫秒,-1表示默认超时
|
||||
* @param streamProgress 进度条
|
||||
* @return 下载大小
|
||||
* @return 文件
|
||||
* @since 5.7.12
|
||||
*/
|
||||
public long downloadFile(final String url, final File targetFileOrDir, final String tempFileSuffix, final int timeout, final StreamProgress streamProgress) {
|
||||
return requestDownload(url, timeout).writeBody(targetFileOrDir, tempFileSuffix, streamProgress);
|
||||
public File downloadFile(final String url, final File targetFileOrDir, final String tempFileSuffix, final int timeout, final StreamProgress streamProgress) {
|
||||
return requestDownload(url, timeout).body().write(targetFileOrDir, tempFileSuffix, streamProgress);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,7 +84,7 @@ public class HttpDownloader {
|
||||
* @return 文件
|
||||
*/
|
||||
public static File downloadForFile(final String url, final File targetFileOrDir, final int timeout, final StreamProgress streamProgress) {
|
||||
return requestDownload(url, timeout).writeBodyForFile(targetFileOrDir, streamProgress);
|
||||
return requestDownload(url, timeout).body().write(targetFileOrDir, streamProgress);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +99,7 @@ public class HttpDownloader {
|
||||
public static long download(final String url, final OutputStream out, final boolean isCloseOut, final StreamProgress streamProgress) {
|
||||
Assert.notNull(out, "[out] is null !");
|
||||
|
||||
return requestDownload(url, -1).writeBody(out, isCloseOut, streamProgress);
|
||||
return requestDownload(url, -1).body().write(out, isCloseOut, streamProgress);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package cn.hutool.http.client.body;
|
||||
|
||||
import cn.hutool.core.io.resource.BytesResource;
|
||||
import cn.hutool.core.io.resource.HttpResource;
|
||||
|
||||
/**
|
||||
* bytes类型的Http request body,主要发送编码后的表单数据或rest body(如JSON或XML)
|
||||
@@ -25,6 +26,6 @@ public class BytesBody extends ResourceBody {
|
||||
* @param content Body内容,编码后
|
||||
*/
|
||||
public BytesBody(final byte[] content) {
|
||||
super(new BytesResource(content));
|
||||
super(new HttpResource(new BytesResource(content), null));
|
||||
}
|
||||
}
|
||||
|
@@ -574,7 +574,7 @@ public class SoapClient extends HttpBase<SoapClient> {
|
||||
* @return 返回结果
|
||||
*/
|
||||
public String send(final boolean pretty) {
|
||||
final String body = sendForResponse().body();
|
||||
final String body = sendForResponse().bodyStr();
|
||||
return pretty ? XmlUtil.format(body) : body;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user