couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From klaus_trai...@apache.org
Subject chttpd commit: updated refs/heads/master to 72258e2
Date Mon, 02 Nov 2015 19:09:05 GMT
Repository: couchdb-chttpd
Updated Branches:
  refs/heads/master 68d40cce7 -> 72258e2f5


Don't set random ETag header for views

This fixes the issue that by setting a random ETag header, we implicitly
promised that there's a chance of a cache hit where there was no chance.

For 2.0, we simply remove the random ETag without replacement, in order
to not accidentally cause useless cache bloat in clients.

COUCHDB-2859


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

Branch: refs/heads/master
Commit: 72258e2f5debfaf270eba2245083a8331ffe1fec
Parents: 68d40cc
Author: Klaus Trainer <klaus_trainer@apache.org>
Authored: Mon Nov 2 18:33:19 2015 +0100
Committer: Klaus Trainer <klaus_trainer@apache.org>
Committed: Mon Nov 2 20:08:10 2015 +0100

----------------------------------------------------------------------
 src/chttpd_view.erl | 44 +++++++++++++-------------------------------
 1 file changed, 13 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/72258e2f/src/chttpd_view.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_view.erl b/src/chttpd_view.erl
index 8da557d..ea86095 100644
--- a/src/chttpd_view.erl
+++ b/src/chttpd_view.erl
@@ -24,41 +24,23 @@ multi_query_view(Req, Db, DDoc, ViewName, Queries) ->
         QueryArg = couch_mrview_http:parse_params(Query, undefined, Args1),
         couch_mrview_util:validate_args(QueryArg)
     end, Queries),
-    {ok, Resp2} = couch_httpd:etag_maybe(Req, fun() ->
-        VAcc0 = #vacc{db=Db, req=Req, prepend="\r\n"},
-        %% TODO: proper calculation of etag
-        Etag = [$", couch_uuids:new(), $"],
-        Headers = [{"ETag", Etag}],
-        FirstChunk = "{\"results\":[",
-        {ok, Resp0} = chttpd:start_delayed_json_response(VAcc0#vacc.req, 200, Headers, FirstChunk),
-        VAcc1 = VAcc0#vacc{resp=Resp0, etag=Etag},
-        VAcc2 = lists:foldl(fun(Args, Acc0) ->
-            {ok, Acc1} = fabric:query_view(Db, DDoc, ViewName, fun couch_mrview_http:view_cb/2,
Acc0, Args),
-            Acc1
-        end, VAcc1, ArgQueries),
-        {ok, Resp1} = chttpd:send_delayed_chunk(VAcc2#vacc.resp, "\r\n]}"),
-        {ok, Resp2} = chttpd:end_delayed_json_response(Resp1),
-        {ok, VAcc2#vacc{resp=Resp2}}
-    end),
-    case is_record(Resp2, vacc) of
-        true -> {ok, Resp2#vacc.resp};
-        _ -> {ok, Resp2}
-    end.
+    VAcc0 = #vacc{db=Db, req=Req, prepend="\r\n"},
+    FirstChunk = "{\"results\":[",
+    {ok, Resp0} = chttpd:start_delayed_json_response(VAcc0#vacc.req, 200, [], FirstChunk),
+    VAcc1 = VAcc0#vacc{resp=Resp0},
+    VAcc2 = lists:foldl(fun(Args, Acc0) ->
+        {ok, Acc1} = fabric:query_view(Db, DDoc, ViewName, fun couch_mrview_http:view_cb/2,
Acc0, Args),
+        Acc1
+    end, VAcc1, ArgQueries),
+    {ok, Resp1} = chttpd:send_delayed_chunk(VAcc2#vacc.resp, "\r\n]}"),
+    chttpd:end_delayed_json_response(Resp1).
 
 
 design_doc_view(Req, Db, DDoc, ViewName, Keys) ->
     Args = couch_mrview_http:parse_params(Req, Keys),
-    %% TODO: proper calculation of etag
-    Etag = [$", couch_uuids:new(), $"],
-    {ok, Resp} = couch_httpd:etag_maybe(Req, fun() ->
-        Max = chttpd:chunked_response_buffer_size(),
-        VAcc0 = #vacc{db=Db, req=Req, threshold=Max, etag=Etag},
-        fabric:query_view(Db, DDoc, ViewName, fun couch_mrview_http:view_cb/2, VAcc0, Args)
-    end),
-    case is_record(Resp, vacc) of
-        true -> {ok, Resp#vacc.resp};
-        _ -> {ok, Resp}
-    end.
+    Max = chttpd:chunked_response_buffer_size(),
+    VAcc = #vacc{db=Db, req=Req, threshold=Max},
+    fabric:query_view(Db, DDoc, ViewName, fun couch_mrview_http:view_cb/2, VAcc, Args).
 
 handle_view_req(#httpd{method='GET',
         path_parts=[_, _, _, _, ViewName]}=Req, Db, DDoc) ->


Mime
View raw message