New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net/http: assume POST has Content-Type: application/x-www-form-urlencoded if missing (IE) #5412
Labels
Milestone
Comments
Comment 1 by lawrence@a4support.com: I've done a work around without understanding what's actually happening, but that fixes the problem of IE: inputJson := httpRequest.FormValue("json") if inputJson == "" { // probably request from IE as inputJson is empty body, _ := ioutil.ReadAll(httpRequest.Body) postField, _ := url.ParseQuery(fmt.Sprintf("%s", body)) // works for IE only inputJson = postField["json"][0] } |
Can you download Wireshark and record your network traffic while sending the AJAX POST? I want to see what headers you're actually sending to App Engine. Please attach the pcap file here. Labels changed: removed priority-triage. Owner changed to @bradfitz. Status changed to WaitingForReply. |
Comment 3 by lawrence@a4support.com: I did it using some other tool and here are the http headers from IE: POST /_api/subscribe HTTP/1.1 Accept: */* Origin: http://www.example.com Accept-Language: en-US Accept-Encoding: gzip, deflate User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; MALC) Host: myapp.appspot.com Content-Length: 92 DNT: 1 Connection: Keep-Alive Cache-Control: no-cache Compared with Chrome: Accept:*/* Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3 Accept-Encoding:gzip,deflate,sdch Accept-Language:en-US,en;q=0.8 Connection:keep-alive Content-Length:92 Content-type:application/x-www-form-urlencoded Host:myapp.appspot.com Origin:http://www.example.com Referer:http://www.example.com/download-draft1-rc1.php User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31 I think the main difference is IE is unable to send the Content-type:application/x-www-form-urlencoded header. This problem is specific to the use of window.XDomainRequest object... which I have to use it anyway as my AJAX works cross domain. By now I have already modified the way my app works, I'm no longer using name/value pairs, instead I just send raw json in the POST BODY and on the server I read the POST request body directly and decode the JSON object. |
Comment 6 by lawrence@a4support.com: That's all right, my solution now is just POST the JSON directly as string and skip using the x-www-form-urlencoded header for all request. Simply read from httpRequest.Body is enough |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by lawrence@a4support.com:
The text was updated successfully, but these errors were encountered: