我正在开发一个小型嵌入式Web服务器。我想添加对帖子请求的解析,但是我遇到了来自Chrome的输入密码字段的问题。 Firefox和IE完美运行。
HTML:
<form action="start.webem" method="post">
<input value="START" type="submit" /><!--#webem start -->
Password: <input type="password" name="yourname" autocomplete="off" />
</form>
从Firefox获得
POST /stop.webem HTTP/1.1
Host: 127.0.0.1:8080
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9) Gecko/20100315 Firefox/3.5.9 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://127.0.0.1:8080/
Content-Type: application/x-www-form-urlencoded
Content-Length: 13
yourname=test
然而,从Chrome开始,大约90%的时间都缺少yourname = test
POST /start.webem HTTP/1.1
Host: 127.0.0.1:8080
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.1.249.1045 Safari/532.5
Referer: http://127.0.0.1:8080/
Content-Length: 13
Cache-Control: max-age=0
Origin: http://127.0.0.1:8080
Content-Type: application/x-www-form-urlencoded
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
虽然偶尔会奏效!!!
POST /start.webem HTTP/1.1
Host: 127.0.0.1:8080
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.1.249.1045 Safari/532.5
Referer: http://127.0.0.1:8080/start.webem
Content-Length: 13
Cache-Control: max-age=0
Origin: http://127.0.0.1:8080
Content-Type: application/x-www-form-urlencoded
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
yourname=test
我找不到导致它工作的原因。
答案 0 :(得分:0)
可能是因为您的HTML无效。解决这个问题,你的问题就会消失......
<form action="start.webem" method="post">
<input value="Start" type="submit" />
<p>
<label for="yourname">Password:</label>
<input id="yourname" name="yourname" type="password" autocomplete="off" />
</p>
</form>
发表评论:
HTML在技术上不区分大小写,但您永远不应该使用大写的标记/属性名称。这只是不好的做法。
我认为它有时起作用的原因是因为你有一个开放的段落标记,但从未关闭它,因此Chrome有时可能会将该段落放在表单之外。
答案 1 :(得分:0)
您有可能没有从Web服务器的套接字读取数据的第二部分。这可能会说明为什么有时它会起作用。