【发布时间】:2015-10-07 12:51:24
【问题描述】:
当我执行一个应该导致重定向的发布请求时,重定向没有得到正确处理。
请求的RAW格式
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]"
每当“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 - 类型状态报告 信息 描述客户端发送的请求在语法上不正确()。 Apache Tomcat/6.0.24
知道如何正确处理重定向吗?当我在 Fiddler 中执行相同的 POST 请求时,请求被正确执行。
【问题讨论】:
标签: soapui fiddler http-status-code-302