Merge pull request #2835 from influxdb/jw-json-writes

Skip leading whitespace when detecting JSON writes without content-type
pull/2838/head
Jason Wilder 2015-06-08 17:49:44 -06:00
commit c1c8c5f0ca
1 changed files with 15 additions and 3 deletions

View File

@ -397,9 +397,21 @@ func (h *Handler) writeError(w http.ResponseWriter, result influxql.Result, stat
func (h *Handler) serveWriteLine(w http.ResponseWriter, r *http.Request, body []byte, user *meta.UserInfo) {
// Some clients may not set the content-type header appropriately and send JSON with a non-json
// content-type. If the body looks JSON, try to handle it as as JSON instead
if len(body) > 0 && body[0] == '{' {
h.serveWriteJSON(w, r, body, user)
return
if len(body) > 0 {
var i int
for {
// JSON requests must start w/ an opening bracket
if body[i] == '{' {
h.serveWriteJSON(w, r, body, user)
return
}
// check that the byte is in the standard ascii code range
if body[i] > 32 {
break
}
i += 1
}
}
precision := r.FormValue("precision")