0
我試圖從嵌入式設備發送POST請求到我的網絡服務器,但Web服務器返回錯誤400給我。HTTP POST請求返回400,SERVER_PORT_SECURE不使用
這要求我派我的服務器的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 {
\t font-family: Verdana, Arial, Helvetica, sans-serif;
\t font-size: 12px;
\t background-color:#367E8E;
\t scrollbar-base-color: #005B70;
\t scrollbar-arrow-color: #F3960B;
\t scrollbar-DarkShadow-Color: #000000;
\t color: #FFFFFF;
\t \t \t margin:0;
}
a { color:#021f25; text-decoration:none}
h1 {
\t font-size: 18px;
\t color: #FB9802;
\t padding-bottom: 10px;
\t background-image: url(sys_cpanel/images/bottombody.jpg);
\t background-repeat: repeat-x;
\t padding:5px 0 10px 15px;
\t \t \t margin:0;
}
#body-content p {
\t padding-left: 25px;
\t padding-right: 25px;
\t line-height: 18px;
\t padding-top: 5px;
\t padding-bottom: 5px;
}
h2 {
\t font-size: 14px;
\t font-weight: bold;
\t color: #FF9900;
\t 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:[email protected]?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
- 沒有子域的主機頭
大家似乎導致同樣的錯誤。
任何人的建議?我錯過了一個標題?標題中是否有錯誤?
任何幫助或建議,非常感謝!
問候, 羅伯特
我看到該請求沒有一個'內容Length'頭。經過一些測試,似乎Apache不需要它,但嘗試添加它。 – Rei