mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
新增followRedirectsCookie配置,支持开启自动重定向携带cookie
This commit is contained in:
@@ -8,19 +8,19 @@ public class RedirectServerTest {
|
||||
|
||||
public static void main(String[] args) {
|
||||
HttpUtil.createServer(8888).addAction("/redirect1", (request, response) -> {
|
||||
response.addHeader(Header.LOCATION.getValue(),"http://localhost:8888/redirect2");
|
||||
response.addHeader(Header.SET_COOKIE.getValue(),"redirect1=1; path=/; HttpOnly");
|
||||
response.addHeader(Header.LOCATION.getValue(), "http://localhost:8888/redirect2");
|
||||
response.addHeader(Header.SET_COOKIE.getValue(), "redirect1=1; path=/; HttpOnly");
|
||||
response.send(301);
|
||||
}).addAction("/redirect2", (request, response) -> {
|
||||
response.addHeader(Header.LOCATION.getValue(),"http://localhost:8888/redirect3");
|
||||
response.addHeader(Header.LOCATION.getValue(), "http://localhost:8888/redirect3");
|
||||
response.addHeader(Header.SET_COOKIE.getValue(), "redirect2=2; path=/; HttpOnly");
|
||||
response.send(301);
|
||||
}).addAction("/redirect3", (request, response) -> {
|
||||
response.addHeader(Header.LOCATION.getValue(),"http://localhost:8888/redirect4");
|
||||
response.addHeader(Header.SET_COOKIE.getValue(),"redirect3=3; path=/; HttpOnly");
|
||||
response.addHeader(Header.LOCATION.getValue(), "http://localhost:8888/redirect4");
|
||||
response.addHeader(Header.SET_COOKIE.getValue(), "redirect3=3; path=/; HttpOnly");
|
||||
response.send(301);
|
||||
}).addAction("/redirect4", (request, response) -> {
|
||||
String cookie = request.getHeader(Header.COOKIE);
|
||||
final String cookie = request.getHeader(Header.COOKIE);
|
||||
Console.log(cookie);
|
||||
response.sendOk();
|
||||
}).start();
|
||||
|
Reference in New Issue
Block a user