2
尝试从路由器网站获取一些数据,但找不到POST请求头。无法使用jSoup POST 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--
解析响应到文档进行打印,它显示我的凭据为无效。难道我的内容类型错了吗?
这里是我的连接代码:
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();
任何有识之士将不胜感激!
在此先感谢!
编辑:解析响应,服务器返回以下错误消息,我相信这进一步加深了我对网站处理Content-Type的处理方式的怀疑。
<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>