HTTP POST请求返回400,未使用SERVER_PORT_SECURE

时间:2017-01-09 12:01:06

标签: http http-post httprequest http-status-code-400 http-1.1

我正在尝试从嵌入式设备向我的网络服务器发送POST请求,但是网络服务器会向我返回错误400.

这是我发送到服务器端口80的请求:

POST /api_back.php HTTP/1.1
Host: mysubdomain.mydomain.com
User-Agent: AppleWebKit/531.21.10
Accept: */*
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
Accept-Charset: utf-8, us-ascii
Pragma: no-cache

data=10,1,1,1,1,-48%0D%0A10,1,1,1,1,-48%0D%0A10,1,1,1,1,-47%0D%0A10,1,1,1,1,-48%0D%0A10,1,1,1,1,-48%0D%0A10,1,1,1,1,-47%0D%0A10,1,1,1,1,-47%0D%0A

然后我收到以下回复:

http/1.1 400 bad request
date: sun, 08 jan 2017 16:59:54 gmt
server: apache/2.4.23 (unix) openssl/1.0.1e-fips mod_bwlimited/1.4
accept-ranges: bytes
connection: close
content-type: text/html



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>400 Bad Request</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
        body {
        	font-family: Verdana, Arial, Helvetica, sans-serif;
        	font-size: 12px;
        	background-color:#367E8E;
        	scrollbar-base-color: #005B70;
        	scrollbar-arrow-color: #F3960B;
        	scrollbar-DarkShadow-Color: #000000;
        	color: #FFFFFF;
			margin:0;
        }
        a { color:#021f25; text-decoration:none}
        h1 {
        	font-size: 18px;
        	color: #FB9802;
        	padding-bottom: 10px;
        	background-image: url(sys_cpanel/images/bottombody.jpg);
        	background-repeat: repeat-x;
        	padding:5px 0 10px 15px;
			margin:0;
        }
        #body-content p {
        	padding-left: 25px;
        	padding-right: 25px;
        	line-height: 18px;
        	padding-top: 5px;
        	padding-bottom: 5px;
        }
        h2 {
        	font-size: 14px;
        	font-weight: bold;
        	color: #FF9900;
        	padding-left: 15px;
        }
    </style>
  </head>
  <body>
    <div id="body-content">  
<!-- start content-->

<!-- 
 instead of REQUEST_URI, we could show absolute URL via:
 http://HTTP_HOST/REQUEST_URI
    but what if its https:// or other protocol?
    
    SERVER_PORT_SECURE doesn't seem to be used
    SERVER_PORT logic would break if they use alternate ports
-->

<h1>400 Bad Request</h1>
<p>Your browser sent a request that this server could not understand:</p>
  <blockquote>
    (none) (port 80)
  </blockquote> 
<p>
    Please forward this error screen to 31.186.174.155's 
    <a href="mailto:noreply@totaalholding.nl?subject=Error message [400] 400 Bad Request for (none) port 80 on Sunday, 08-Jan-2017 17:59:54 CET">
    WebMaster</a>.
</p>
<hr />


<!-- end content -->
    </div>
  </body>
</html>

错误似乎表明主机名或请求uri是错误的,所以我也尝试了POST链接中的整个URL:

POST http://mysubdomain.mydomain.com/api_back.php HTTP/1.1
Host: mysubdomain.mydomain.com
...

也没有运气。我试过的其他事情

  • 不同的用户代理
  • HTTP / 1.0
  • 主机标头中没有子域

所有这些似乎都会导致同样的错误。

有人提出建议吗?我错过了标题吗?标题中是否有错误?

非常感谢任何帮助或建议!

此致 罗伯特

1 个答案:

答案 0 :(得分:0)

对于那些寻找类似问题的人;问题是,逗号显然不是帖子请求中的有效字符,urlencode逗号和生活再次好:)