GET请求NodeMCU(ESP8266)301错误

时间:2015-11-02 20:24:39

标签: .htaccess redirect esp8266 nodemcu

前几天我发布了有关nodeMcu POST请求的问题,找不到任何我正在尝试的解决方案:

conn=net.createConnection(net.TCP, 0)
conn:on("receive", function(conn, payload) print(payload) end )
conn:on("connection", function(c)
conn:send("GET /wifi?temp=24&hum=12&alert HTTP/1.1\r\n"
.."Host: www.weatherman.bl.ee\r\n"
.."Cache-Control: no-cache\r\n"
.."Connection: keep-alive\r\nAccept: */*\r\n\r\n")
end)
conn:connect(80, "www.weatherman.bl.ee")

但是这个请求回复了我的错误

HTTP/1.1 301 Moved Permanently 
Date: Mon, 02 Nov 2015 20:03:50 GMT
Server: Apache
Location: http://www.weatherman.bl.ee/wifi/?temp=24&hum=12&alert
Content-Length: 270
Keep-Alive: timeout=2, max=100 
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1

有什么想法吗?可能是标题的问题? 邮差执行请求罚款

2 个答案:

答案 0 :(得分:1)

服务器可能会在请求URL路径的末尾强制执行/

如果您使用额外/的网址,重定向响应会尝试重定向您,则您不应该收到301回复。

/wifi/?temp=24&hum=12&alert
     ↑
     └ extra slash

答案 1 :(得分:0)

状态301不是错误,200-399之间的所有内容都被视为成功。在301的情况下,将有一个位置标头,用于构建重定向的URL。服务器返回301以响应给定的URL,您在客户端上唯一可以做的事情(除了使用位置跟随它)使用不同的URL。

相关问题