当我执行一个post请求时,这个请求应该导致重定向,这个重定向没有得到正确的处理。
请求的原始格式
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 Moved Temporarily”
日志
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]"每当“跟随重定向”设置为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 -类型状态报告消息说明客户端发送的请求在语法上不正确()。Apache Tomcat/6.0.24
你知道如何正确处理重定向吗?当我在Fiddler中执行相同的POST请求时,请求被正确执行。
发布于 2015-10-13 15:44:59
这听起来像是应该应用Post/Redirect/Get。从您的日志中看,它似乎再次执行了投递/重定向/投递。用于重定向帖子请求的行为最近在Ready中更改了!API SoapUI NG PROF1.4.1将发布/重定向/获取,希望这在这种情况下会有所帮助。
https://stackoverflow.com/questions/32992701
复制相似问题