HTTP POST-запрос отвечает 400 неверным запросом - PullRequest
0 голосов
/ 10 октября 2019

Я подключил Arduino к Интернету с помощью модуля esp8266. Мультисенсорная информация должна быть отправлена ​​на сервер, а php-файл будет извлечен и сохранен в базе данных. Все части системы работают нормально. Есть всего лишь одна проблема. Мне нужно отправить информацию по почте, но я получаю ошибку 400, отправив следующий код.

код:

POST /myfile.php HTTP/1.1\n
Host: mysite.ir\n
Content-Type: application/x-www-form-urlencoded\n
User-Agent: PostmanRuntime/7.17.1\n
Accept: */*\n
Cache-Control: no-cache\n
Postman-Token: d4960545-7b37-429a-9096-2bff70d365b0,eff629b0-8db2-4ced-b9ba-603dc3982685\n
Host: mysite.ir\n
Accept-Encoding: gzip, deflate\n
Content-Length: 37\n
Cookie: PHPSESSID=4emkpfpnp5aq821o96plafqop4\n
Connection: keep-alive\n
cache-control: no-cache\n\n
temp=70&hum=50&bright=650&rele_lamp=1

Я сгенерировал этот код с помощью программного обеспечения почтальона.

ответ:

+IPD,1383:HTTP/1.1 400 Bad Request
Cache-Control: private, no-cache, no-store, must-revalidate, max-age=0
Pragma: no-cache
Content-Type: text/html
Content-Length: 1121
Date: Thu, 10 Oct 2019 14:15:02 GMT
Accept-Ranges: bytes
Server: LiteSpeed
Connection: close

<!DOCTYPE html>
<html style="height:100%">
<head><title> 400 Bad Request
</title></head>
<body style="color: #444; margin:0;font: normal 14px/20px Arial, Helvetica, sans-serif; height:100%; background-color: #fff;">
<div style="height:auto; min-height:100%; ">     <div style="text-align: center; width:800px; margin-left: -400px; position:absolute; top: 30%; left:50%;">
<h1 style="margin:0; font-size:150px; line-height:150px; font-weight:bold;">400</h1>
<h2 style="margin-top:20px;font-size: 30px;">Bad Request
</h2>
<p>It is not a valid request!</p>
</div></div><div style="color:#f0f0f0; font-size:12px;margin:auto;padding:0px 30px 0px 30px;position:relative;clear:both;height:100px;margin-top:-101px;background-color:#474747;border-top: 1px solid rgba(0,0,0,0.15);box-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) inset;">
<br>Proudly powered by  <a style="color:#fff;" href="http://www.litespeedtech.com/error-page">LiteSpeed Web Server</a>         <p>Please be advised that LiteSpeed Technologies Inc. is not a web hosting company and, as such, has no control over content found on this site.</p>   </div></body></html>

Я пробовал много кода, но получил ошибку 400. Я не знаю, в чем проблема. Спасибо за помощь.

1 Ответ

0 голосов
/ 11 октября 2019

Спасибо, juraj

Я попробовал новый код, полученный с помощью программного обеспечения ARC, и снова получил ошибку. Я поместил полный код ниже.

код:

AT


OK
AT+RST


OK

ets Jan  8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x40100000, len 612, room 16 
tail 4
chksum 0x12
load 0x3ffe8000, len 788, room 4 
tail 0
chksum 0x50
load 0x3ffe8314, len 264, room 8 
tail 0
chksum 0x4a
csum 0x4a

2nd boot version : 1.1
  SPI Speed      : 40MHz
  SPI Mode       : DIO
  SPI Flash Size : 4Mbit
jump to run user1

rlS
ready
AT+CIPSTART="TCP","mysite.ir",80

CONNECT

OK
AT+CIPSEND=154

> POST /myfile.php HTTP/1.1\r\nHost: mysite.ir:80\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\ntemp=70&hum=20&bright=400&rele_lamp=1\r\n\r\n
busy s...

SEND OK

+IPD,1383:HTTP/1.1 400 Bad Request
Cache-Control: private, no-cache, no-store, must-revalidate, max-age=0
Pragma: no-cache
Content-Type: text/html
Content-Length: 1121
Date: Fri, 11 Oct 2019 07:10:56 GMT
Accept-Ranges: bytes
Server: LiteSpeed
Connection: close

<!DOCTYPE html>
<html style="height:100%">
<head><title> 400 Bad Request
</title></head>
<body style="color: #444; margin:0;font: normal 14px/20px Arial, Helvetica, sans-serif; height:100%; background-color: #fff;">
<div style="height:auto; min-height:100%; ">     <div style="text-align: center; width:800px; margin-left: -400px; position:absolute; top: 30%; left:50%;">
    <h1 style="margin:0; font-size:150px; line-height:150px; font-weight:bold;">400</h1>
   <h2 style="margin-top:20px;font-size: 30px;">Bad Request
   </h2>
   <p>It is not a valid request!</p>
   </div></div><div style="color:#f0f0f0; font-size:12px;margin:auto;padding:0px 30px 0px 30px;position:relative;clear:both;height:100px;margin-top:-101px;background-color:#474747;border-top: 1px solid rgba(0,0,0,0.15);box-shadow: 0 1px 0 rgba(255, 255, 255, 0.3) inset;">
   <br>Proudly powered by  <a style="color:#fff;" href="http://www.litespeedtech.com/error-page">LiteSpeed Web Server</a><p>Please be advised that LiteSpeed Technologies Inc. is not a web hosting company and, as such, has no control over content found on this site.</p></div></body></html>

   OK
   CLOSED

    OK

Этот код работает с программным обеспечением ARC, и сервер отвечает правильно. Но когда я отправляю модуль, я получаю сообщение об ошибке.

...