当我执行应该导致重定向的帖子请求时,重定向不会被处理。
POST https://XXX.XXX.XXX.XXX:8443/Manager/securitycheck.vod HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 37
Host: XXX.XXX.XXX.XXX:8443
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.3.1 (java 1.5)
with following body
j_username=testuser&j_password=testpass
将“Follow Redirects”设置为false,上面的请求以“HTTP / 1.1 302暂时移动”回复
Tue Oct 06 10:38:58 CEST 2015DEBUG: >> "POST /Manager/securitycheck.vod HTTP/1.1[\r][\n]"
Tue Oct 06 10:38:58 CEST 2015DEBUG: >> "Accept-Encoding: gzip,deflate[\r][\n]"
Tue Oct 06 10:38:58 CEST 2015DEBUG: >> "Content-Type: application/x-www-form-urlencoded [\r][\n]"
Tue Oct 06 10:38:58 CEST 2015DEBUG: >> "Content-Length: 37[\r][\n]"
Tue Oct 06 10:38:58 CEST 2015DEBUG: >> "Host: XXX.XXX.XXX.XXX:8443[\r][\n]"
Tue Oct 06 10:38:58 CEST 2015DEBUG: >> "Connection: Keep-Alive[\r][\n]"
Tue Oct 06 10:38:58 CEST 2015DEBUG: >> "User-Agent: Apache-HttpClient/4.3.1 (java 1.5)[\r][\n]"
Tue Oct 06 10:38:58 CEST 2015DEBUG: >> "[\r][\n]"
Tue Oct 06 10:38:58 CEST 2015DEBUG: >> "j_username=testuser&j_password=testpass"
Tue Oct 06 10:39:03 CEST 2015DEBUG: << "HTTP/1.1 302 Moved Temporarily[\r][\n]"
Tue Oct 06 10:39:03 CEST 2015DEBUG: << "Server: Apache-Coyote/1.1[\r][\n]"
Tue Oct 06 10:39:03 CEST 2015DEBUG: << "Set-Cookie: JSESSIONID=444269D02E53BB0155909417A5DAF809; Path=/Manager; Secure[\r][\n]"
Tue Oct 06 10:39:03 CEST 2015DEBUG: << "Location: https://XXX.XXX.XXX.XXX:8443/Manager/lay.vod;jsessionid=444269D02E53BB0155909417A5DAF809[\r][\n]"
Tue Oct 06 10:39:03 CEST 2015DEBUG: << "Content-Language: en-US[\r][\n]"
Tue Oct 06 10:39:03 CEST 2015DEBUG: << "Content-Length: 0[\r][\n]"
Tue Oct 06 10:39:03 CEST 2015DEBUG: << "Date: Tue, 06 Oct 2015 08:39:03 GMT[\r][\n]"
Tue Oct 06 10:39:03 CEST 2015DEBUG: << "[\r][\n]"
每当“Follow Redirects”设置为true时,我就会遇到400错误请求。
Tue Oct 06 10:40:54 CEST 2015DEBUG: >> "POST /Manager/securitycheck.vod HTTP/1.1[\r][\n]"
Tue Oct 06 10:40:54 CEST 2015DEBUG: >> "Accept-Encoding: gzip,deflate[\r][\n]"
Tue Oct 06 10:40:54 CEST 2015DEBUG: >> "Content-Type: application/x-www-form-urlencoded [\r][\n]"
Tue Oct 06 10:40:54 CEST 2015DEBUG: >> "Content-Length: 37[\r][\n]"
Tue Oct 06 10:40:54 CEST 2015DEBUG: >> "Host: XXX.XXX.XXX.XXX:8443[\r][\n]"
Tue Oct 06 10:40:54 CEST 2015DEBUG: >> "Connection: Keep-Alive[\r][\n]"
Tue Oct 06 10:40:54 CEST 2015DEBUG: >> "User-Agent: Apache-HttpClient/4.3.1 (java 1.5)[\r][\n]"
Tue Oct 06 10:40:54 CEST 2015DEBUG: >> "[\r][\n]"
Tue Oct 06 10:40:54 CEST 2015DEBUG: >> "j_username=testuser&j_password=testpass"
Tue Oct 06 10:40:58 CEST 2015DEBUG: << "HTTP/1.1 302 Moved Temporarily[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: << "Server: Apache-Coyote/1.1[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: << "Set-Cookie: JSESSIONID=AD2E5269FB5E759E49BFB4B9A927DDFD; Path=/DVRManager; Secure[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: << "Location: https://XXX.XXX.XXX.XXX:8443/Manager/lay.vod;jsessionid=AD2E5269FB5E759E49BFB4B9A927DDFD[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: << "Content-Language: en-US[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: << "Content-Length: 0[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: << "Date: Tue, 06 Oct 2015 08:40:58 GMT[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: << "[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: >> "POST /Manager/lay.vod;jsessionid=AD2E5269FB5E759E49BFB4B9A927DDFD HTTP/1.1[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: >> "Accept-Encoding: gzip,deflate[\r] [\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: >> "Content-Type: application/json[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: >> "Host: XXX.XXX.XXX.XXX[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: >> "Content-Length: 37[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: >> "Connection: Keep-Alive[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: >> "User-Agent: Apache-HttpClient/4.3.1 (java 1.5)[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: >> "Cookie: JSESSIONID=AD2E5269FB5E759E49BFB4B9A927DDFD[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: >> "Cookie2: $Version=1[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: >> "[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: >> "j_username=testuser&j_password=testpass"
Tue Oct 06 10:40:58 CEST 2015DEBUG: << "HTTP/1.1 400 Bad Request[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: << "Server: Apache-Coyote/1.1[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: << "Content-Type: text/html;charset=utf-8[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: << "Content-Length: 971[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: << "Date: Tue, 06 Oct 2015 08:40:58 GMT[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: << "Connection: close[\r][\n]"
Tue Oct 06 10:40:58 CEST 2015DEBUG: << "[\r][\n]"
结果
HTTP状态400 - 类型状态报告 信息 description客户端发送的请求在语法上是不正确的()。 Apache Tomcat / 6.0.24
知道如何正确处理重定向吗?当我在Fiddler中执行相同的POST请求时,请求被正确执行。
答案 0 :(得分:0)
听起来应该应用Post/Redirect/Get。从您的日志看起来它再次发布/重定向/发布。最近在Ready中更改了重定向Post请求的行为! API SoapUI NG Pro 1.4.1将发布/重定向/获取,希望在这种情况下有所帮助。