我正在尝试使用httpclient来使用受密码保护的restful服务。请求订单是:
client -> server CONNECT
server <- client 200 Connection established
client -> server POST
server <- client 401 Authorization Required
client -> server POST (with Authorization header added)
我有一些httpclient 3示例代码,我可以看到在收到401响应后处理cookie,接受cookie并使用第二个POST请求发回它们,但是在httpclient 4中这些cookie被忽略。查看源代码时,MainClientExec#execute
似乎应该处理响应标头并在删除AUTH.WWW_AUTH_RESP
和AUTH.PROXY_AUTH_RESP
标头时修改请求。
忽略服务器是否正常运行的问题有没有办法让这项工作开箱即用?我不愿意使用遗留版本的httpclient。