Skip to content

net/http: assume POST has Content-Type: application/x-www-form-urlencoded if missing (IE) #5412

Closed
@gopherbot

Description

@gopherbot

by lawrence@a4support.com:

This is the same Issue as on
https://code.google.com/p/googleappengine/issues/detail?id=9270
(i'm not sure where should I report this, thus placing to both)

This is very annoying bug and I'm not sure it's originates from IE or GAE, but I hope
GAE have some ways to work around in case it's IE's nonsense.

first of all, my partial code:

func subscribeHandle(httpResponse http.ResponseWriter, httpRequest *http.Request) {
    inputJson := httpRequest.FormValue("json")
    // debug the input
    appContext.Debugf("inputJson: %s", inputJson)
    appContext.Debugf("Body: %s", httpRequest.Body)
}

The request body as sent from browsers:
json=%7B%22email%22%3A%22user%40example.com%22%2C%22newsletter%22%3A%22imapbuilder%22%7D

The GAE log trace for Chrome:
2013-05-06 10:03:00.494
inputJson:
{"email":"user@example.com","newsletter":"imapbuilder"}
D 2013-05-06 10:03:00.494
Body: &{%!s(*bytes.Reader=&{[106 115 111 110 61 37 55 66 37 50 50 101 109 97 105
108 37 50 50 37 51 65 37 50 50 117 115 101 114 37 52 48 101 120 97 109 112 108 101 46 99
111 109 37 50 50 37 50 67 37 50 50 110 101 119 115 108 101 116 116 101 114 37 50 50 37
51 65 37 50 50 105 109 97 112 98 117 105 108 100 101 114 37 50 50 37 55 68] 88 -1})
%!s(bool=false)}

The GAE log trace for IE:
2013-05-06 10:02:37.121
inputJson: 
D 2013-05-06 10:02:37.121
Body: &{%!s(*bytes.Reader=&{[106 115 111 110 61 37 55 66 37 50 50 101 109 97 105
108 37 50 50 37 51 65 37 50 50 117 115 101 114 37 52 48 101 120 97 109 112 108 101 46 99
111 109 37 50 50 37 50 67 37 50 50 110 101 119 115 108 101 116 116 101 114 37 50 50 37
51 65 37 50 50 105 109 97 112 98 117 105 108 100 101 114 37 50 50 37 55 68] 0 -1})
%!s(bool=false)}

So...the httpRequest.FormValue is completely empty for IE's request, while from the
httpRequest.Body the bytes are almost all there except there's a small difference the
second last value (88 vs 0).. I think it's the content length.

Any idea how we can solve this? Otherwise IE's AJAX POST will never work with GAE as GAE
can't read any of the data.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions