Commit ab7f9522 authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Explicitly set response Content-Type header in successful HTTP RPC responses.

parent a9b82285
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
- Correctly apply optimistic concurrency controls to individual storage objects under high write contention.
- Time spent metrics are now correctly reported in milliseconds.
- Password minimum length error message now correctly reflects the constraint.
- Explicitly set response Content-Type header in successful HTTP RPC responses.

## [2.7.0] - 2019-09-11
### Added
+7 −0
Original line number Diff line number Diff line
@@ -191,6 +191,13 @@ func (s *ApiServer) RpcFuncHttp(w http.ResponseWriter, r *http.Request) {
		response = []byte(result)
	}
	w.WriteHeader(http.StatusOK)
	if contentType := r.Header["Content-Type"]; unwrap && len(contentType) > 0 {
		// Assume the request input content type is the same as the expected response.
		w.Header().Set("content-type", contentType[0])
	} else {
		// Fall back to default response content type application/json.
		w.Header().Set("content-type", "application/json")
	}
	_, err := w.Write(response)
	if err != nil {
		s.logger.Debug("Error writing response to client", zap.Error(err))