Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 1 commit
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Commits on Oct 18, 2011
Robert Newson support jsonp in externals 9c2b447
Showing with 11 additions and 6 deletions.
  1. +11 −6 src/chttpd_external.erl
View
17 src/chttpd_external.erl
@@ -114,16 +114,21 @@ json_query_keys([{<<"key">>, Value} | Rest], Acc) ->
json_query_keys([Term | Rest], Acc) ->
json_query_keys(Rest, [Term|Acc]).
-send_external_response(#httpd{mochi_req=MochiReq}, Response) ->
+send_external_response(Req, Response) ->
#extern_resp_args{
code = Code,
data = Data,
ctype = CType,
- headers = Headers
+ headers = Headers,
+ json = Json
} = parse_external_response(Response),
- Resp = MochiReq:respond({Code,
- default_or_content_type(CType, Headers ++ chttpd:server_header()), Data}),
- {ok, Resp}.
+ Headers1 = default_or_content_type(CType, Headers),
+ case Json of
+ nil ->
+ couch_httpd:send_response(Req, Code, Headers1, Data);
+ Json ->
+ couch_httpd:send_json(Req, Code, Headers1, Json)
+ end.
parse_external_response({Response}) ->
lists:foldl(fun({Key,Value}, Args) ->
@@ -136,7 +141,7 @@ parse_external_response({Response}) ->
Args#extern_resp_args{stop=true};
{<<"json">>, Value} ->
Args#extern_resp_args{
- data=?JSON_ENCODE(Value),
+ json=Value,
ctype="application/json"};
{<<"body">>, Value} ->
Args#extern_resp_args{data=Value, ctype="text/html; charset=utf-8"};

No commit comments for this range

Something went wrong with that request. Please try again.