简体   繁体   English

Post 请求在 ESP8266 上看起来像 2 个不同的请求。 这是 Chrome 的错误吗?

[英]Post request looks like 2 different requests on ESP8266. Is this a Chrome bug?

I am setting up a server on ESP8266 WiFi module.我正在 ESP8266 WiFi 模块上设置服务器。 Basic operation is, you request a URL.基本操作是,您请求一个 URL。 ESP serves that page. ESP 为该页面提供服务。 It has a form.它有一个形式。 You fill it in and click submit, and the browser sends POST request by AJAX.填好后点击提交,浏览器通过AJAX发送POST请求。 I am not using jQuery, just js.我没有使用 jQuery,只是使用 js。 From Chrome dev-tools, it looks like all is well.从 Chrome 开发工具来看,看起来一切都很好。

But on the ESP Server side, I noticed I am missing post data once in a while.但是在 ESP 服务器端,我注意到我偶尔会丢失发布数据。 After digging deep, I found this issue.深入挖掘后,我发现了这个问题。

Ideal result from Chrome on my windows: And this works correctly. Chrome 在我的 Windows 上的理想结果:这可以正常工作。 Post data comes in as expected.发布数据按预期进入。

+IPD,0,507:POST /wifi.htm HTTP/1.1
Host: 192.168.4.1
Connection: keep-alive
Content-Length: 63
Origin: http://192.168.4.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36
Content-Type: text/plain;charset=UTF-8
Accept: */*
Referer: http://192.168.4.1/wifi.htm
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
AlexaToolbar-ALX_NS_PH: AlexaToolbar/alx-4.0

ethOrWiFi=1&ewln=1&dhcp=1&ssid=Esensors&key=tgfgfdgfdtrd&auth=4

But on my Mac Chrome, I see the following result.但是在我的 Mac Chrome 上,我看到了以下结果。

+IPD,0,472:POST /wifi.htm HTTP/1.1
Host: 192.168.4.1
Connection: keep-alive
Content-Length: 63
Origin: http://192.168.4.1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36
Content-Type: text/plain;charset=UTF-8
Accept: */*
DNT: 1
Referer: http://192.168.4.1/wifi.htm
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8,ml;q=0.6
AlexaToolbar-ALX_NS_PH: AlexaToolbar/alx-4.0

+IPD,0,63:ethOrWiFi=1&ewln=1&dhcp=1&ssid=Esensors&key=asdfasdfasdf&auth=4

And I can repeat this.我可以重复这一点。 The only different in each case is I am using Chrome on Windows as opposed to Chrome on Mac.在每种情况下唯一不同的是我在 Windows 上使用 Chrome,而不是在 Mac 上使用 Chrome。 To double check, I downloaded Chrome canary version and tried.为了仔细检查,我下载了Chrome canary version并尝试了。 The first request worked fine.第一个请求工作正常。 From second request onwards, it shows this problem.从第二个请求开始,它显示了这个问题。 Why is this happening?为什么会这样? Any ideas?有任何想法吗? May be my laptop has issues?可能是我的笔记本电脑有问题? :) :)

Here are Chrome dev-tools info from Chrome on Mac (the one with the problem)这是来自 Mac 上 Chrome 的 Chrome 开发工具信息(有问题的那个)

**Request Headers:**
POST /wifi.htm HTTP/1.1
Host: 192.168.4.1
Connection: keep-alive
Content-Length: 61
Origin: http://192.168.4.1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36
Content-Type: text/plain;charset=UTF-8
Accept: */*
DNT: 1
Referer: http://192.168.4.1/wifi.htm
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8,ml;q=0.6
AlexaToolbar-ALX_NS_PH: AlexaToolbar/alx-4.0
**Request Payload**
ethOrWiFi=1&ewln=1&dhcp=1&ssid=Esensors&key=asdfasdfoi&auth=4

+IPD is the AT command that says data was received from the network. +IPD 是 AT 命令,表示从网络接收到数据。 +IPD,0,63: is saying to receive 63 bytes from connection 0. That matches with your Content-Length header. +IPD,0,63:表示从连接 0 接收 63 个字节。这与您的Content-Length标头匹配。 Notice that it also appears at the beginning of the header portion of the request.请注意,它也出现在请求的标头部分的开头。

Your WiFi library on the ESP side is throwing that in. Here and on line 281 is the source code where it might be happening.您在 ESP 端的 WiFi 库将其投入使用。 此处和第 281 行是可能发生的源代码。 There are a couple variables that affect whether or not the +IPD is added, maybe you have set or inadvertently changed one.有几个变量会影响是否添加 +IPD,也许您已经设置或无意中更改了一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM