mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
HttpRequest#get不再尝试File路径
This commit is contained in:
parent
deb2d98a2e
commit
dd4390508e
@ -113,7 +113,7 @@ public final class UrlBuilder implements Builder<String> {
|
||||
if(false == StrUtil.startWithAnyIgnoreCase(httpUrl, "http://", "https://")){
|
||||
httpUrl = "http://" + httpUrl;
|
||||
}
|
||||
return of(httpUrl, charset);
|
||||
return of(URLUtil.toUrlForHttp(httpUrl), charset);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,7 +135,7 @@ public final class UrlBuilder implements Builder<String> {
|
||||
*/
|
||||
public static UrlBuilder of(String url, Charset charset) {
|
||||
Assert.notBlank(url, "Url must be not blank!");
|
||||
return of(URLUtil.urlForNet(StrUtil.trim(url)), charset);
|
||||
return of(URLUtil.url(StrUtil.trim(url)), charset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -164,22 +164,6 @@ public class URLUtil extends URLEncodeUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据提供的路径创建一个URL对象,如果给定路径非网络协议路径直接抛出异常
|
||||
*
|
||||
* @param path 表示URL路径的字符串。
|
||||
* @return 返回一个新创建的URL对象。
|
||||
* @throws UtilException 如果给定的路径不能构造一个有效的URL,则抛出UtilException。
|
||||
* @since 5.8.28
|
||||
*/
|
||||
public static URL urlForNet(String path) throws UtilException{
|
||||
try {
|
||||
return new URL(path);
|
||||
} catch (MalformedURLException e) {
|
||||
throw new UtilException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取string协议的URL,类似于string:///xxxxx
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user