GET 请求 NodeMCU(ESP8266) 301 错误

GET request NodeMCU(ESP8266) 301 Error

几天前我 post 关于 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")

但是这个请求返回 301 错误

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

有什么想法吗?可能是 header 的问题? 邮递员执行请求很好

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

如果您将 URL 与额外的 / 一起使用,重定向响应会尝试对您进行重定向,您应该不会收到 301 响应。

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

状态 301 不是错误,从 200-399 的一切都被认为是成功的。在 301 的情况下,将有一个位置 header,您可以使用它来构建重定向的 URL。服务器返回 301 以响应给定的 URL,您在客户端唯一可以做的(除了使用位置来跟踪它)是使用不同的 URL.