You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2015/11/27 18:20:10 UTC

couch commit: updated refs/heads/master to 3a519b2

Repository: couchdb-couch
Updated Branches:
  refs/heads/master c38ab6b2d -> 3a519b2d1


Always send application/json response type

Modern browsers (I tested Firefox, Safari, Chrome) will render an
application/json response body as text in a fixed width font. This
ease of display motivated the text/plain vs application/json
negotiation.

It is now obsolete. Let's always send application/json content type.

COUCHDB-2905


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/3a519b2d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/3a519b2d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/3a519b2d

Branch: refs/heads/master
Commit: 3a519b2d19b81be414bbc1d9ea410ea0ec9f903f
Parents: c38ab6b
Author: Robert Newson <rn...@apache.org>
Authored: Fri Nov 27 16:53:58 2015 +0000
Committer: Robert Newson <rn...@apache.org>
Committed: Fri Nov 27 17:16:40 2015 +0000

----------------------------------------------------------------------
 src/couch_httpd.erl | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/3a519b2d/src/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd.erl b/src/couch_httpd.erl
index daa43d5..ef89873 100644
--- a/src/couch_httpd.erl
+++ b/src/couch_httpd.erl
@@ -970,27 +970,13 @@ send_chunked_error(Resp, Error) ->
 send_redirect(Req, Path) ->
      send_response(Req, 301, [{"Location", absolute_uri(Req, Path)}], <<>>).
 
-negotiate_content_type(Req) ->
+negotiate_content_type(_Req) ->
     case get(jsonp) of
-        no_jsonp -> negotiate_content_type1(Req);
-        [] -> negotiate_content_type1(Req);
+        no_jsonp -> "application/json";
+        [] -> "application/json";
         _Callback -> "application/javascript"
     end.
 
-negotiate_content_type1(#httpd{mochi_req=MochiReq}) ->
-    %% Determine the appropriate Content-Type header for a JSON response
-    %% depending on the Accept header in the request. A request that explicitly
-    %% lists the correct JSON MIME type will get that type, otherwise the
-    %% response will have the generic MIME type "text/plain"
-    AcceptedTypes = case MochiReq:get_header_value("Accept") of
-        undefined       -> [];
-        AcceptHeader    -> string:tokens(AcceptHeader, ", ")
-    end,
-    case lists:member("application/json", AcceptedTypes) of
-        true  -> "application/json";
-        false -> "text/plain; charset=utf-8"
-    end.
-
 server_header() ->
     [{"Server", "CouchDB/" ++ couch_server:get_version() ++
                 " (Erlang OTP/" ++ erlang:system_info(otp_release) ++ ")"}].