mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix code
This commit is contained in:
parent
9fb11f6525
commit
0189434df8
@ -1060,4 +1060,12 @@ public class DateUtilTest {
|
||||
DateUtil.parse(sourceStr));
|
||||
Assert.assertTrue(between);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isLastDayTest(){
|
||||
final DateTime dateTime = DateUtil.parse("2022-09-30");
|
||||
final int dayOfMonth = DateUtil.getLastDayOfMonth(dateTime);
|
||||
Assert.assertEquals(dayOfMonth, Objects.requireNonNull(dateTime).dayOfMonth());
|
||||
Assert.assertTrue("not is last day of this month !!",DateUtil.isLastDayOfMonth(dateTime));
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import cn.hutool.core.io.resource.FileResource;
|
||||
import cn.hutool.core.io.resource.MultiFileResource;
|
||||
import cn.hutool.core.io.resource.Resource;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.map.TableMap;
|
||||
import cn.hutool.core.net.ssl.SSLUtil;
|
||||
@ -1226,7 +1227,23 @@ 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);
|
||||
}
|
||||
|
||||
Console.log(redirectUrl);
|
||||
setUrl(redirectUrl);
|
||||
if (redirectCount < config.maxRedirectCount) {
|
||||
redirectCount++;
|
||||
// 重定向不再走过滤器
|
||||
|
20
hutool-http/src/test/java/cn/hutool/http/IssueI5TPSYTest.java
Executable file
20
hutool-http/src/test/java/cn/hutool/http/IssueI5TPSYTest.java
Executable file
@ -0,0 +1,20 @@
|
||||
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());
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ import cn.hutool.poi.excel.StyleSet;
|
||||
import cn.hutool.poi.excel.cell.setters.CellSetterFactory;
|
||||
import cn.hutool.poi.excel.cell.values.ErrorCellValue;
|
||||
import cn.hutool.poi.excel.cell.values.NumericCellValue;
|
||||
import cn.hutool.poi.excel.editors.TrimEditor;
|
||||
import cn.hutool.poi.excel.cell.editors.TrimEditor;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellStyle;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.poi.excel.editors;
|
||||
package cn.hutool.poi.excel.cell.editors;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.poi.excel.editors;
|
||||
package cn.hutool.poi.excel.cell.editors;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
|
@ -3,4 +3,4 @@
|
||||
* @author looly
|
||||
*
|
||||
*/
|
||||
package cn.hutool.poi.excel.editors;
|
||||
package cn.hutool.poi.excel.cell.editors;
|
Loading…
x
Reference in New Issue
Block a user