Author: fdmanana
Date: Fri Jan  7 14:04:08 2011
New Revision: 1056324

URL: http://svn.apache.org/viewvc?rev=1056324&view=rev
Log:
Minor cleanups in couch_httpd

Modified:
    couchdb/trunk/src/couchdb/couch_httpd.erl

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=1056324&r1=1056323&r2=1056324&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Fri Jan  7 14:04:08 2011
@@ -235,7 +235,7 @@ handle_request_int(MochiReq, DefaultFun,
 
     % alias HEAD to GET as mochiweb takes care of stripping the body
     Method = case Method2 of
-            'HEAD' -> 'GET';
+        'HEAD' -> 'GET';
         Other -> Other
     end,
 
@@ -243,10 +243,9 @@ handle_request_int(MochiReq, DefaultFun,
         mochi_req = MochiReq,
         peer = MochiReq:get(peer),
         method = Method,
-        requested_path_parts = [list_to_binary(couch_httpd:unquote(Part))
-                || Part <- string:tokens(RequestedPath, "/")],
-        path_parts = [list_to_binary(couch_httpd:unquote(Part))
-                || Part <- string:tokens(Path, "/")],
+        requested_path_parts =
+            [?l2b(unquote(Part)) || Part <- string:tokens(RequestedPath, "/")],
+        path_parts = [?l2b(unquote(Part)) || Part <- string:tokens(Path, "/")],
         db_url_handlers = DbUrlHandlers,
         design_url_handlers = DesignUrlHandlers,
         default_fun = DefaultFun,
@@ -341,7 +340,7 @@ validate_referer(Req) ->
     end.
 
 validate_ctype(Req, Ctype) ->
-    case couch_httpd:header_value(Req, "Content-Type") of
+    case header_value(Req, "Content-Type") of
     undefined ->
         throw({bad_ctype, "Content-Type must be "++Ctype});
     ReqCtype ->
@@ -497,21 +496,21 @@ doc_etag(#doc{revs={Start, [DiskRev|_]}}
 
 make_etag(Term) ->
     <<SigInt:128/integer>> = couch_util:md5(term_to_binary(Term)),
-    list_to_binary("\"" ++ lists:flatten(io_lib:format("~.36B",[SigInt])) ++ 
"\"").
+    iolist_to_binary([$", io_lib:format("~.36B", [SigInt]), $"]).
 
 etag_match(Req, CurrentEtag) when is_binary(CurrentEtag) ->
     etag_match(Req, binary_to_list(CurrentEtag));
 
 etag_match(Req, CurrentEtag) ->
     EtagsToMatch = string:tokens(
-        couch_httpd:header_value(Req, "If-None-Match", ""), ", "),
+        header_value(Req, "If-None-Match", ""), ", "),
     lists:member(CurrentEtag, EtagsToMatch).
 
 etag_respond(Req, CurrentEtag, RespFun) ->
     case etag_match(Req, CurrentEtag) of
     true ->
         % the client has this in their cache.
-        couch_httpd:send_response(Req, 304, [{"Etag", CurrentEtag}], <<>>);
+        send_response(Req, 304, [{"Etag", CurrentEtag}], <<>>);
     false ->
         % Run the function.
         RespFun()
@@ -830,8 +829,7 @@ send_chunked_error(Resp, Error) ->
     last_chunk(Resp).
 
 send_redirect(Req, Path) ->
-     Headers = [{"Location", couch_httpd:absolute_uri(Req, Path)}],
-     send_response(Req, 301, Headers, <<>>).
+     send_response(Req, 301, [{"Location", absolute_uri(Req, Path)}], <<>>).
 
 negotiate_content_type(#httpd{mochi_req=MochiReq}) ->
     %% Determine the appropriate Content-Type header for a JSON response
@@ -864,13 +862,13 @@ parse_multipart_request(ContentType, Dat
             data_fun=DataFun,
             callback=Callback},
     {Mp2, _NilCallback} = read_until(Mp, <<"--", Boundary0/binary>>,
-        fun(Next)-> nil_callback(Next) end),
+        fun nil_callback/1),
     #mp{buffer=Buffer, data_fun=DataFun2, callback=Callback2} =
             parse_part_header(Mp2),
     {Buffer, DataFun2, Callback2}.
 
 nil_callback(_Data)->
-    fun(Next) -> nil_callback(Next) end.
+    fun nil_callback/1.
 
 get_boundary({"multipart/" ++ _, Opts}) ->
     case couch_util:get_value("boundary", Opts) of


Reply via email to