parent
a91b3f3e8b
commit
0af8be35bb
@ -29,16 +29,20 @@ func requestToProto(r *http.Request) (*api.Request, error) {
|
|||||||
|
|
||||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ct = "application/x-www-form-urlencoded"
|
ct = "text/plain; charset=UTF-8" //default CT is text/plain
|
||||||
r.Header.Set("Content-Type", ct)
|
r.Header.Set("Content-Type", ct)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ct {
|
//set the body:
|
||||||
case "application/x-www-form-urlencoded":
|
if r.Body != nil {
|
||||||
// expect form vals
|
switch ct {
|
||||||
default:
|
case "application/x-www-form-urlencoded":
|
||||||
data, _ := ioutil.ReadAll(r.Body)
|
// expect form vals in Post data
|
||||||
req.Body = string(data)
|
default:
|
||||||
|
|
||||||
|
data, _ := ioutil.ReadAll(r.Body)
|
||||||
|
req.Body = string(data)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set X-Forwarded-For if it does not exist
|
// Set X-Forwarded-For if it does not exist
|
||||||
|
Loading…
Reference in New Issue
Block a user