summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_httpd.erl
diff options
context:
space:
mode:
authorDamien F. Katz <damien@apache.org>2008-04-20 18:17:15 +0000
committerDamien F. Katz <damien@apache.org>2008-04-20 18:17:15 +0000
commitfb5b6bbc5aa941478d700e8fb3011c2a24c4d2d4 (patch)
treebcc23ed4869f395e894f76ec3fb5e76f75a5ba98 /src/couchdb/couch_httpd.erl
parentad230e67fb09883e2171291d5a42635f5e2addb9 (diff)
Added proper UUID generation and changed the details of how way debug logging is done to now use a more effcient macro instead of a function call.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@649948 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd.erl')
-rw-r--r--src/couchdb/couch_httpd.erl28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index ad60d7ca..31bdd143 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -57,11 +57,11 @@ handle_request(Req, DocumentRoot) ->
% removed, but URL quoting left intact
{Path, _, _} = mochiweb_util:urlsplit_path(Req:get(raw_path)),
- couch_log:debug("Version: ~p", [Req:get(version)]),
- couch_log:debug("Method: ~p", [Method]),
- couch_log:debug("Request URI: ~p", [Path]),
- couch_log:debug("Headers: ~p", [mochiweb_headers:to_list(Req:get(headers))]),
-
+ ?LOG_DEBUG("Version: ~p", [Req:get(version)]),
+ ?LOG_DEBUG("Method: ~p", [Method]),
+ ?LOG_DEBUG("Request URI: ~p", [Path]),
+ ?LOG_DEBUG("Headers: ~p", [mochiweb_headers:to_list(Req:get(headers))]),
+
{ok, Resp} = case catch(handle_request(Req, DocumentRoot, Method, Path)) of
{ok, Resp0} ->
{ok, Resp0};
@@ -69,13 +69,19 @@ handle_request(Req, DocumentRoot) ->
send_error(Req, Error)
end,
- couch_log:info("~s - - ~p ~B", [
+ ?LOG_INFO("~s - - ~p ~B", [
Req:get(peer),
atom_to_list(Req:get(method)) ++ " " ++ Path,
Resp:get(code)
]).
handle_request(Req, DocumentRoot, Method, Path) ->
+ Start = erlang:now(),
+ X = handle_request0(Req, DocumentRoot, Method, Path),
+ io:format("now_diff:~p~n", [timer:now_diff(erlang:now(), Start)]),
+ X.
+
+handle_request0(Req, DocumentRoot, Method, Path) ->
case Path of
"/" ->
handle_welcome_request(Req, Method);
@@ -431,7 +437,7 @@ handle_doc_request(Req, 'GET', _DbName, Db, DocId) ->
JsonDoc = couch_doc:to_json_obj(Doc, Options),
AdditionalHeaders =
case Doc#doc.meta of
- [] -> [{"Etag", Etag}]; % output etag when we have no meta
+ [] -> [{"XEtag", Etag}]; % output etag when we have no meta
_ -> []
end,
send_json(Req, 200, AdditionalHeaders, JsonDoc);
@@ -498,7 +504,7 @@ handle_doc_request(Req, 'PUT', _DbName, Db, DocId) ->
Doc = couch_doc:from_json_obj(Json),
{ok, NewRev} = couch_db:update_doc(Db, Doc#doc{id=DocId, revs=Revs}, []),
- send_json(Req, 201, [{"Etag", "\"" ++ NewRev ++ "\""}], {obj, [
+ send_json(Req, 201, [{"XEtag", "\"" ++ NewRev ++ "\""}], {obj, [
{ok, true},
{id, DocId},
{rev, NewRev}
@@ -791,12 +797,12 @@ error_to_json0(Error) ->
send_error(Req, {method_not_allowed, Methods}) ->
{ok, Req:respond({405, [{"Allow", Methods}], <<>>})};
send_error(Req, {modified, Etag}) ->
- {ok, Req:respond({412, [{"Etag", Etag}], <<>>})};
+ {ok, Req:respond({412, [{"XEtag", Etag}], <<>>})};
send_error(Req, {not_modified, Etag}) ->
- {ok, Req:respond({304, [{"Etag", Etag}], <<>>})};
+ {ok, Req:respond({304, [{"XEtag", Etag}], <<>>})};
send_error(Req, Error) ->
{Code, Json} = error_to_json(Error),
- couch_log:info("HTTP Error (code ~w): ~p", [Code, Error]),
+ ?LOG_INFO("HTTP Error (code ~w): ~p", [Code, Error]),
send_error(Req, Code, Json).
send_error(Req, Code, Json) ->