summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_httpd_db.erl
diff options
context:
space:
mode:
authorRobert Newson <rnewson@apache.org>2010-09-30 13:00:48 +0000
committerRobert Newson <rnewson@apache.org>2010-09-30 13:00:48 +0000
commitced8d0138b1946568536a73edd9d92312e300003 (patch)
tree15c2f9fced218c64f58d64805d7a83d0bd2e0a56 /src/couchdb/couch_httpd_db.erl
parentf64b4a4bd7ac4c833271591f62010288270bfb93 (diff)
fix badmatch for COPY call with missing Destination header.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1003050 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd_db.erl')
-rw-r--r--src/couchdb/couch_httpd_db.erl22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index 93e93892..51c9ae9a 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -1216,15 +1216,19 @@ extract_header_rev(Req, ExplicitRev) ->
parse_copy_destination_header(Req) ->
- Destination = couch_httpd:header_value(Req, "Destination"),
- case re:run(Destination, "\\?", [{capture, none}]) of
- nomatch ->
- {list_to_binary(Destination), {0, []}};
- match ->
- [DocId, RevQs] = re:split(Destination, "\\?", [{return, list}]),
- [_RevQueryKey, Rev] = re:split(RevQs, "=", [{return, list}]),
- {Pos, RevId} = couch_doc:parse_rev(Rev),
- {list_to_binary(DocId), {Pos, [RevId]}}
+ case couch_httpd:header_value(Req, "Destination") of
+ undefined ->
+ throw({bad_request, "Destination header in mandatory for COPY."});
+ Destination ->
+ case re:run(Destination, "\\?", [{capture, none}]) of
+ nomatch ->
+ {list_to_binary(Destination), {0, []}};
+ match ->
+ [DocId, RevQs] = re:split(Destination, "\\?", [{return, list}]),
+ [_RevQueryKey, Rev] = re:split(RevQs, "=", [{return, list}]),
+ {Pos, RevId} = couch_doc:parse_rev(Rev),
+ {list_to_binary(DocId), {Pos, [RevId]}}
+ end
end.
validate_attachment_names(Doc) ->