代码之家  ›  专栏  ›  技术社区  ›  ravenspoint

Web服务器解析post请求的chrome输入

  •  1
  • ravenspoint  · 技术社区  · 16 年前

    我正在开发一个小型嵌入式web服务器。我想添加post请求的解析,但是我在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> 
    

    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=测试都没有出现

    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
    

    我有时找不到什么原因使它起作用。

    2 回复  |  直到 16 年前
        1
  •  0
  •   loislo    16 年前

    很可能您没有从web服务器的套接字读取第二部分数据。这也许可以解释为什么有时它是有效的。

        2
  •  0
  •   Amy B    16 年前

    <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有时可能会把段落放在表单之外。