Use the Accept header for determining the Content-Type instead of Content-Type

The `Content-Type` header is meant to say what the content type of the
request is supposed to be and `Accept` is used to ask for a specific
content type. I messed this up and used `Content-Type` instead of
`Accept`. This works with `GET` requests accidentally, but `POST`
requests stop working.
pull/7098/head
Jonathan A. Sternberg 2016-07-29 14:29:39 -05:00
parent 4a89ab4482
commit 73bbbf24b1
1 changed files with 3 additions and 3 deletions

View File

@ -14,11 +14,11 @@ type ResponseWriter interface {
http.ResponseWriter
}
// NewResponseWriter creates a new ResponseWriter based on the Content-Type of the request
// that wraps the ResponseWriter.
// NewResponseWriter creates a new ResponseWriter based on the Accept header
// in the request that wraps the ResponseWriter.
func NewResponseWriter(w http.ResponseWriter, r *http.Request) ResponseWriter {
pretty := r.URL.Query().Get("pretty") == "true"
switch r.Header.Get("Content-Type") {
switch r.Header.Get("Accept") {
case "application/json":
fallthrough
default: