Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

response type fixed

  • Loading branch information...
commit 2a8a631cd6b16b0f6a98c2f75a495efd68df4057 1 parent 3855199
Eugene Volchek evolchek authored committed
2  src/rfc4627_jsonrpc_inets.erl
@@ -161,7 +161,7 @@ do_rpc(#mod{init_data = #init_data{peername = {PeerPort, PeerName}},
161 161 {proceed, [{response, {response,
162 162 [{code, 200},
163 163 {content_length, integer_to_list(length(ResultEnc))},
164   - {content_type, "text/plain"}%rfc4627:mime_type()}
  164 + {content_type, rfc4627:mime_type()}
165 165 | Headers],
166 166 ResultEnc}} | OldData]}
167 167 end.
11 src/rfc4627_jsonrpc_mochiweb.erl
@@ -99,8 +99,17 @@ handle(AliasPrefix, Req) ->
99 99 no_match ->
100 100 no_match;
101 101 {ok, ResultEnc, ResponseInfo} ->
  102 + DefaultType = rfc4627:mime_type(),
  103 + RespType = case Req:accepts_content_type(DefaultType) of
  104 + true -> DefaultType;
  105 + false ->
  106 + case Req:accepts_content_type("text/plain") of
  107 + true -> "text/plain";
  108 + false -> DefaultType
  109 + end
  110 + end,
102 111 {obj, ResponseHeaderFields} =
103 112 rfc4627:get_field(ResponseInfo, "http_headers", {obj, []}),
104 113 Headers = [{K, binary_to_list(V)} || {K,V} <- ResponseHeaderFields],
105   - {ok, {200, Headers ++ [{"Content-type", "text/plain"}], ResultEnc}}
  114 + {ok, {200, Headers ++ [{"Content-type", RespType}], ResultEnc}}
106 115 end.

0 comments on commit 2a8a631

Please sign in to comment.
Something went wrong with that request. Please try again.