couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iil...@apache.org
Subject [3/6] chttpd commit: updated refs/heads/master to ab299eb
Date Tue, 15 Mar 2016 17:45:27 GMT
Extract basic_headers/2 function

COUCHDB-2966


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/b32f2b6c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/b32f2b6c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/b32f2b6c

Branch: refs/heads/master
Commit: b32f2b6cb4df9ee82b779bf5aa097bf006eca468
Parents: 599b095
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Tue Mar 8 08:32:24 2016 -0800
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Tue Mar 15 10:43:56 2016 -0700

----------------------------------------------------------------------
 src/chttpd.erl | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/b32f2b6c/src/chttpd.erl
----------------------------------------------------------------------
diff --git a/src/chttpd.erl b/src/chttpd.erl
index 56b6445..673465e 100644
--- a/src/chttpd.erl
+++ b/src/chttpd.erl
@@ -506,11 +506,8 @@ serve_file(Req, RelativePath, DocumentRoot) ->
 
 serve_file(#httpd{mochi_req=MochiReq}=Req, RelativePath, DocumentRoot,
            ExtraHeaders) ->
-    Headers = server_header() ++
-	couch_httpd_auth:cookie_auth_header(Req, []) ++
-	ExtraHeaders,
-    Headers1 = chttpd_cors:headers(Req, Headers),
-    {ok, MochiReq:serve_file(RelativePath, DocumentRoot, Headers1)}.
+    Headers = basic_headers(Req, ExtraHeaders),
+    {ok, MochiReq:serve_file(RelativePath, DocumentRoot, Headers)}.
 
 qs_value(Req, Key) ->
     qs_value(Req, Key, undefined).
@@ -660,10 +657,8 @@ verify_is_server_admin(#httpd{user_ctx=#user_ctx{roles=Roles}}) ->
 
 start_response_length(#httpd{mochi_req=MochiReq}=Req, Code, Headers0, Length) ->
     couch_stats:increment_counter([couchdb, httpd_status_codes, Code]),
-    Headers1 = Headers0 ++ server_header() ++
-	couch_httpd_auth:cookie_auth_header(Req, Headers0),
-    Headers2 = chttpd_cors:headers(Req, Headers1),
-    Resp = MochiReq:start_response_length({Code, Headers2, Length}),
+    Headers1 = basic_headers(Req, Headers0),
+    Resp = MochiReq:start_response_length({Code, Headers1, Length}),
     case MochiReq:get(method) of
     'HEAD' -> throw({http_head_abort, Resp});
     _ -> ok
@@ -676,10 +671,8 @@ send(Resp, Data) ->
 
 start_chunked_response(#httpd{mochi_req=MochiReq}=Req, Code, Headers0) ->
     couch_stats:increment_counter([couchdb, httpd_status_codes, Code]),
-    Headers1 = Headers0 ++ server_header() ++
-        couch_httpd_auth:cookie_auth_header(Req, Headers0),
-    Headers2 = chttpd_cors:headers(Req, Headers1),
-    Resp = MochiReq:respond({Code, Headers2, chunked}),
+    Headers1 = basic_headers(Req, Headers0),
+    Resp = MochiReq:respond({Code, Headers1, chunked}),
     case MochiReq:get(method) of
     'HEAD' -> throw({http_head_abort, Resp});
     _ -> ok
@@ -1068,3 +1061,9 @@ stack_hash(Stack) ->
 %% dedicated chunk.
 chunked_response_buffer_size() ->
     config:get_integer("httpd", "chunked_response_buffer", 1490).
+
+basic_headers(Req, Headers0) ->
+    Headers = Headers0
+        ++ server_header()
+        ++ couch_httpd_auth:cookie_auth_header(Req, Headers0),
+    chttpd_cors:headers(Req, Headers).


Mime
View raw message