Permalink
Browse files

Replace JSON w/ MessagePack for non-chunked responses.

  • Loading branch information...
1 parent 3c1a0d7 commit b601286dae04bdc2488a0d9bf028c58e6feb3449 @timanglade committed Aug 19, 2011
Showing with 400 additions and 3 deletions.
  1. +3 −3 src/couchdb/couch_httpd.erl
  2. +397 −0 src/couchdb/msgpack.erl
@@ -481,7 +481,7 @@ body(#httpd{mochi_req=MochiReq, req_body=ReqBody}) ->
end.
json_body(Httpd) ->
- ?JSON_DECODE(body(Httpd)).
+ hd(msgpack:unpack_all(body(Httpd))).
json_body_obj(Httpd) ->
case json_body(Httpd) of
@@ -620,10 +620,10 @@ send_json(Req, Code, Value) ->
send_json(Req, Code, Headers, Value) ->
DefaultHeaders = [
- {"Content-Type", negotiate_content_type(Req)},
+ {"Content-Type", "application/x-msgpack"},
{"Cache-Control", "must-revalidate"}
],
- Body = [start_jsonp(Req), ?JSON_ENCODE(Value), end_jsonp(), $\n],
+ Body = msgpack:pack(Value),
send_response(Req, Code, DefaultHeaders ++ Headers, Body).
start_json_response(Req, Code) ->
Oops, something went wrong.

0 comments on commit b601286

Please sign in to comment.