From 254fc2ac67ab1e5452cc3fd11aadfe3b0aa805e1 Mon Sep 17 00:00:00 2001 From: Christopher Lenz Date: Fri, 19 Dec 2008 22:26:34 +0000 Subject: Fix Etag checking for document requests: need to convert Etag header value to binary early, as the `ExplicitRev` is already a binary, thus the comparison would fail. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@728177 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_httpd_db.erl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl index fbea4541..119c20ee 100644 --- a/src/couchdb/couch_httpd_db.erl +++ b/src/couchdb/couch_httpd_db.erl @@ -612,18 +612,18 @@ parse_doc_query(Req) -> -extract_header_rev(Req, ExplictRev) when is_list(ExplictRev)-> - extract_header_rev(Req, list_to_binary(ExplictRev)); -extract_header_rev(Req, ExplictRev) -> +extract_header_rev(Req, ExplicitRev) when is_list(ExplicitRev)-> + extract_header_rev(Req, list_to_binary(ExplicitRev)); +extract_header_rev(Req, ExplicitRev) -> Etag = case couch_httpd:header_value(Req, "If-Match") of undefined -> undefined; - Tag -> string:strip(Tag, both, $") + Value -> list_to_binary(string:strip(Value, both, $")) end, - case {ExplictRev, Etag} of + case {ExplicitRev, Etag} of {undefined, undefined} -> missing_rev; - {_, undefined} -> ExplictRev; - {undefined, _} -> list_to_binary(Etag); - _ when ExplictRev == Etag -> list_to_binary(Etag); + {_, undefined} -> ExplicitRev; + {undefined, _} -> Etag; + _ when ExplicitRev == Etag -> Etag; _ -> throw({bad_request, "Document rev and etag have different values"}) end. -- cgit v1.2.3