Jersey 客户端卡在 SAML GET 请求上
Jersey client stuck on SAML GET request
我在 Java 中使用 ApacheHttpClient4
向 SAML url (https://en.wikipedia.org/wiki/SAML_2.0) 发送 GET 请求时遇到问题。我从上一个请求获得的位置 header 获取 url,返回 302。然后我在 url 上执行 GET,格式为 https://some.domain/?SAMLRequest=...&RelayState=...
. Jersey 以某种方式卡在上面并且永远不会发送实际请求(我已经检查了 Charles 并启用了日志过滤器但是 GET 从未发生过,它甚至没有尝试)。它卡在以下行:
PoolingClientConnectionManager - Connection request: [route: {tls}->http://127.0.0.1:8888->https://some.domain][total kept alive: 3; route allocated: 2 of 2; total allocated: 7 of 20]
这是一个艰难的过程,但我最终设法通过向客户端添加一个 ClientFilter 来解决它,它只执行以下操作:
/**
* This class is only used to solve cases where a Client gets stuck in a redirect process.
*/
public class MyClientFilter extends ClientFilter {
@Override
public ClientResponse handle(ClientRequest clientRequest) throws ClientHandlerException {
return getNext().handle(clientRequest);
}
}
它设法以某种方式强制客户端继续遵循重定向。
我在 Java 中使用 ApacheHttpClient4
向 SAML url (https://en.wikipedia.org/wiki/SAML_2.0) 发送 GET 请求时遇到问题。我从上一个请求获得的位置 header 获取 url,返回 302。然后我在 url 上执行 GET,格式为 https://some.domain/?SAMLRequest=...&RelayState=...
. Jersey 以某种方式卡在上面并且永远不会发送实际请求(我已经检查了 Charles 并启用了日志过滤器但是 GET 从未发生过,它甚至没有尝试)。它卡在以下行:
PoolingClientConnectionManager - Connection request: [route: {tls}->http://127.0.0.1:8888->https://some.domain][total kept alive: 3; route allocated: 2 of 2; total allocated: 7 of 20]
这是一个艰难的过程,但我最终设法通过向客户端添加一个 ClientFilter 来解决它,它只执行以下操作:
/**
* This class is only used to solve cases where a Client gets stuck in a redirect process.
*/
public class MyClientFilter extends ClientFilter {
@Override
public ClientResponse handle(ClientRequest clientRequest) throws ClientHandlerException {
return getNext().handle(clientRequest);
}
}
它设法以某种方式强制客户端继续遵循重定向。