From 59a89fd650f4c419c5b2a6ea50ad6b1610fa8a10 Mon Sep 17 00:00:00 2001 From: Christopher Lenz Date: Fri, 23 May 2008 19:27:52 +0000 Subject: Patch MochiWeb for compatibility with R11B. This patch has been rejected upstream, but it's simple enough to just apply here. git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@659636 13f79535-47bb-0310-9956-ffa450edef68 --- src/mochiweb/mochiweb_util.erl | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/mochiweb/mochiweb_util.erl') diff --git a/src/mochiweb/mochiweb_util.erl b/src/mochiweb/mochiweb_util.erl index 7b66877d..e7026194 100644 --- a/src/mochiweb/mochiweb_util.erl +++ b/src/mochiweb/mochiweb_util.erl @@ -11,6 +11,7 @@ -export([guess_mime/1, parse_header/1]). -export([shell_quote/1, cmd/1, cmd_string/1, cmd_port/2]). -export([record_to_proplist/2, record_to_proplist/3]). +-export([to_lower/1]). -export([test/0]). -define(PERCENT, 37). % $\% @@ -170,7 +171,7 @@ urlsplit_scheme(Url) -> urlsplit_scheme([], Acc) -> {"", lists:reverse(Acc)}; urlsplit_scheme(":" ++ Rest, Acc) -> - {string:to_lower(lists:reverse(Acc)), Rest}; + {to_lower(lists:reverse(Acc)), Rest}; urlsplit_scheme([C | Rest], Acc) -> urlsplit_scheme(Rest, [C | Acc]). @@ -322,11 +323,11 @@ parse_header(String) -> %% Skip anything with no value Acc; {Name, [$\= | Value]} -> - [{string:to_lower(string:strip(Name)), + [{to_lower(string:strip(Name)), unquote_header(string:strip(Value))} | Acc] end end, - {string:to_lower(Type), + {to_lower(Type), lists:foldr(F, [], Parts)}. unquote_header("\"" ++ Rest) -> @@ -369,6 +370,20 @@ shell_quote([C | Rest], Acc) when C =:= $\" orelse C =:= $\` orelse shell_quote([C | Rest], Acc) -> shell_quote(Rest, [C | Acc]). +to_lower_char(C) when is_integer(C), C >= $A, C =< $Z -> + C + 32; +to_lower_char(C) when is_integer(C), C >= 16#C1, C =< 16#D6 -> + C + 32; +to_lower_char(C) when is_integer(C), C >= 16#D8, C =< 16#DE -> + C + 32; +to_lower_char(C) -> + C. + +to_lower(S) when is_list(S) -> + [to_lower_char(C) || C <- S]; +to_lower(C) when is_integer(C) -> + to_lower_char(C). + test() -> test_join(), test_quote_plus(), -- cgit v1.2.3