Apache ESP8266向网站发送数据错误请求
我想向Apache服务器发送一些文本,但出现了一些错误 我是ESP2866的新手 我找不到原因 我收到:“400个错误请求”…。请求头字段缺少“:”分隔符:Apache ESP8266向网站发送数据错误请求,apache,arduino,esp8266,Apache,Arduino,Esp8266,我想向Apache服务器发送一些文本,但出现了一些错误 我是ESP2866的新手 我找不到原因 我收到:“400个错误请求”…。请求头字段缺少“:”分隔符: 然后我收到了一些错误: 语法错误…… 我将以下标头发送到服务器: POST/receiver.php HTTP/1.1 主机:192.168.1.9 内容类型:application/x-www-form-urlencoded 内容长度:20 温度=35 我在Arduino中使用此代码: String cmd,aaa; aaa="tem
然后我收到了一些错误: 语法错误…… 我将以下标头发送到服务器: POST/receiver.php HTTP/1.1 主机:192.168.1.9 内容类型:application/x-www-form-urlencoded 内容长度:20 温度=35 我在Arduino中使用此代码:
String cmd,aaa;
aaa="temp="+35;
cmd= "POST /temp.php HTTP/1.1\r\n";
cmd+="Host: 192.168.1.9\r\n";
cmd+="Content-Type: text/plain\r\nContent-Length: "+aaa.length();
cmd+="\r\n\r\n"+aaa+"\r\n\r\n";
Serial.print("Sending to Server: ");
aaa= "AT+CIPSEND=";
aaa+=cmd.length();
aaa+="\r\n";
Serial.println(sendData(aaa, 1000));
Serial.println(sendData(cmd,2000));
delay(1000);
这是sendData函数:
String sendData(String command, const int timeout)
{
String response = "";
esp.print(command); // send the read character to the esp8266
long int time = millis();
while ( (time + timeout) > millis())
{
while (esp.available())
{
// The esp has data so display its output to the serial window
char c = esp.read(); // read the next character.
response += c;
}
}
return response;
}
服务器报告“请求标头字段丢失”错误。看起来您缺少“发件人”和“用户代理”标题
“错误语法”错误可能是由ESP8266产生的,我目前也遇到了同样的问题