mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:20:07 +08:00
fix bugs
This commit is contained in:
parent
42a427193b
commit
4212d47bc2
@ -3,10 +3,12 @@
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# 5.8.9.M1 (2022-09-26)
|
||||
# 5.8.9.M1 (2022-09-30)
|
||||
|
||||
### 🐣新特性
|
||||
### 🐞Bug修复
|
||||
* 【poi 】 修复ExcelReader读取只有标题行报错问题(issue#I5U1JA@Gitee)
|
||||
* 【http 】 修复Http重定向时相对路径导致的问题(issue#I5TPSY@Gitee)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -1236,7 +1236,20 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
||||
|
||||
if (responseCode != HttpURLConnection.HTTP_OK) {
|
||||
if (HttpStatus.isRedirected(responseCode)) {
|
||||
setUrl(UrlBuilder.ofHttpWithoutEncode(httpConnection.header(Header.LOCATION)));
|
||||
final UrlBuilder redirectUrl;
|
||||
String location = httpConnection.header(Header.LOCATION);
|
||||
if(false == HttpUtil.isHttp(location) && false == HttpUtil.isHttps(location)){
|
||||
// issue#I5TPSY
|
||||
// location可能为相对路径
|
||||
if(false == location.startsWith("/")){
|
||||
location = StrUtil.addSuffixIfNot(this.url.getPathStr(), "/") + location;
|
||||
}
|
||||
redirectUrl = UrlBuilder.of(this.url.getScheme(), this.url.getHost(), this.url.getPort()
|
||||
, location, null, null, this.charset);
|
||||
} else{
|
||||
redirectUrl = UrlBuilder.ofHttpWithoutEncode(location);
|
||||
}
|
||||
setUrl(redirectUrl);
|
||||
if (redirectCount < config.maxRedirectCount) {
|
||||
redirectCount++;
|
||||
// 重定向不再走过滤器
|
||||
|
19
hutool-http/src/test/java/cn/hutool/http/IssueI5TPSYTest.java
Executable file
19
hutool-http/src/test/java/cn/hutool/http/IssueI5TPSYTest.java
Executable file
@ -0,0 +1,19 @@
|
||||
package cn.hutool.http;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.net.HttpCookie;
|
||||
|
||||
public class IssueI5TPSYTest {
|
||||
@Test
|
||||
@Ignore
|
||||
public void redirectTest() {
|
||||
final String url = "https://bsxt.gdzwfw.gov.cn/UnifiedReporting/auth/newIndex";
|
||||
final HttpResponse res = HttpUtil.createGet(url).setFollowRedirects(true)
|
||||
.cookie(new HttpCookie("iPlanetDirectoryPro", "123"))
|
||||
.execute();
|
||||
Console.log(res.body());
|
||||
}
|
||||
}
|
@ -46,13 +46,14 @@ public class MapSheetReader extends AbstractSheetReader<List<Map<String, Object>
|
||||
} else if (headerRowIndex > lastRowNum) {
|
||||
throw new IndexOutOfBoundsException(StrUtil.format("Header row index {} is greater than last row index {}.", headerRowIndex, lastRowNum));
|
||||
} else if (startRowIndex > lastRowNum) {
|
||||
throw new IndexOutOfBoundsException(StrUtil.format("startRowIndex row index {} is greater than last row index {}.", startRowIndex, lastRowNum));
|
||||
// issue#I5U1JA 只有标题行的Excel,起始行是1,标题行(最后的行号是0)
|
||||
return ListUtil.empty();
|
||||
}
|
||||
final int startRowIndex = Math.max(this.startRowIndex, firstRowNum);// 读取起始行(包含)
|
||||
final int endRowIndex = Math.min(this.endRowIndex, lastRowNum);// 读取结束行(包含)
|
||||
|
||||
// 读取header
|
||||
List<String> headerList = aliasHeader(readRow(sheet, headerRowIndex));
|
||||
final List<String> headerList = aliasHeader(readRow(sheet, headerRowIndex));
|
||||
|
||||
final List<Map<String, Object>> result = new ArrayList<>(endRowIndex - startRowIndex + 1);
|
||||
List<Object> rowList;
|
||||
|
Loading…
Reference in New Issue
Block a user