Permalink
Browse files

add possibility to specify http status code

  • Loading branch information...
1 parent 7a3ad6a commit 4ac63e35db28fafdb492271cbaffabd9a881e414 valeriy committed with May 15, 2012
Showing with 10 additions and 2 deletions.
  1. +5 −1 src/rfc4627_jsonrpc_inets.erl
  2. +5 −1 src/rfc4627_jsonrpc_mochiweb.erl
@@ -161,9 +161,13 @@ do_rpc(#mod{init_data = #init_data{peername = {PeerPort, PeerName}},
{ok, ResultEnc, ResponseInfo} ->
{obj, ResponseHeaderFields} =
rfc4627:get_field(ResponseInfo, "http_headers", {obj, []}),
+
+ StatusCode =
+ rfc4627:get_field(ResponseInfo, "http_status_code", 200),
+
Headers = [{K, binary_to_list(V)} || {K,V} <- ResponseHeaderFields],
{proceed, [{response, {response,
- [{code, 200},
+ [{code, StatusCode},
{content_length, integer_to_list(length(ResultEnc))},
{content_type, rfc4627:mime_type()}
| Headers],
@@ -110,6 +110,10 @@ handle(AliasPrefix, Req) ->
end,
{obj, ResponseHeaderFields} =
rfc4627:get_field(ResponseInfo, "http_headers", {obj, []}),
+
+ StatusCode =
+ rfc4627:get_field(ResponseInfo, "http_status_code", 200),
+
Headers = [{K, binary_to_list(V)} || {K,V} <- ResponseHeaderFields],
- {ok, {200, Headers ++ [{"Content-type", RespType}], ResultEnc}}
+ {ok, {StatusCode, Headers ++ [{"Content-type", RespType}], ResultEnc}}
end.

0 comments on commit 4ac63e3

Please sign in to comment.