From 69360c426a49286b8d32cc9022af3c02a362cdf2 Mon Sep 17 00:00:00 2001 From: Filipe David Borba Manana Date: Sun, 1 Aug 2010 23:30:15 +0000 Subject: Bug fix - RegExp matching the atom 'undefined'. According to the HTTP 1.1 spec, if the Accept header is not specified by a client, it means the client accepts all media types. http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@981341 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_httpd.erl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl index 23ff7f99..4d1bd2ea 100644 --- a/src/couchdb/couch_httpd.erl +++ b/src/couchdb/couch_httpd.erl @@ -777,7 +777,16 @@ error_headers(#httpd{mochi_req=MochiReq}=Req, Code, ErrorStr, ReasonStr) -> {Code, [{"WWW-Authenticate", "Basic realm=\"server\""}]}; _False -> % if the accept header matches html, then do the redirect. else proceed as usual. - case re:run(MochiReq:get_header_value("Accept"), "html", [{capture, none}]) of + Accepts = case MochiReq:get_header_value("Accept") of + undefined -> + % According to the HTTP 1.1 spec, if the Accept + % header is missing, it means the client accepts + % all media types. + "html"; + Else -> + Else + end, + case re:run(Accepts, "html", [{capture, none}, caseless]) of nomatch -> {Code, []}; match -> -- cgit v1.2.3