试图从路由器网站中获取一些数据,但无法找出 POST 请求标头。
这是请求标头:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:342
Content-Type:multipart/form-data; boundary=----WebKitFormBoundary6C8rEu8jENa10v7s
Cookie:AIROS_SESSIONID=48f1f0f41859ba467e3a2bf1de1f6dd0; ui_language=en_US
Host:10.0.0.2
Origin:http://10.0.0.2
Referer:http://10.0.0.2/login.cgi?uri=/index.cgi
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36
这是请求有效负载:
------WebKitFormBoundary6C8rEu8jENa10v7s
Content-Disposition: form-data; name="uri"
/index.cgi
------WebKitFormBoundary6C8rEu8jENa10v7s
Content-Disposition: form-data; name="username"
ubnt
------WebKitFormBoundary6C8rEu8jENa10v7s
Content-Disposition: form-data; name="password"
ubnt
------WebKitFormBoundary6C8rEu8jENa10v7s--
将响应解析为文档并打印,它显示我的凭据无效。会不会是我的 Content-Type 弄错了?
这是我的连接代码:
res1 = Jsoup.connect("http://10.0.0.2/login.cgi")
.userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:25.0) Gecko/20100101 Firefox/25.0")
.header("Content-Type", "multipart/form-data")
.followRedirects(false)
.referrer("http://10.0.0.2/login.cgi?uri=/index.cgi")
.data("uri", "/index.cgi")
.data("username", "ubnt").data("password", "ubnt")
.method(Method.POST).execute();
任何见解将不胜感激!
提前致谢!
编辑:解析响应,服务器返回以下错误消息,我相信这进一步怀疑它与网站处理内容类型的方式有关。
<body>
<b>File Upload Error: No MIME boundary found</b>
<br />
<b>There should have been a "boundary=something" in the Content-Type string</b>
<br />
<b>The Content-Type string was: "multipart/form-data"</b>
<br />
<b><i>l10n.inc:</i> Oops, SetCookie called after header has been sent on line 98</b>
<br />
<tt> setcookie("ui_language", $active_language, 2147483647<b>
<blink>
); /* last valid 32 bit time_t */
</blink></b></tt>