Skip to content

Commit

Permalink
ignore case when looking for "charset"
Browse files Browse the repository at this point in the history
RF2616 says: "The type, subtype, and parameter attribute names are
case-insensitive."

https://tools.ietf.org/html/rfc2616#section-3.7
  • Loading branch information
aG0aep6G committed Aug 8, 2016
1 parent 9d65668 commit 84f7662
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion std/net/curl.d
Original file line number Diff line number Diff line change
Expand Up @@ -2403,7 +2403,7 @@ struct HTTP
if (fieldName == "content-type")
{
auto mct = match(cast(char[]) m.captures[2],
regex("charset=([^;]*)"));
regex("charset=([^;]*)", "i"));
if (!mct.empty && mct.captures.length > 1)
charset = mct.captures[1].idup;
}
Expand Down Expand Up @@ -3144,6 +3144,26 @@ struct HTTP

} // HTTP

unittest // charset/Charset/CHARSET/...
{
import std.meta: AliasSeq;

foreach (c; AliasSeq!("charset", "Charset", "CHARSET", "CharSet", "charSet",
"ChArSeT", "cHaRsEt"))
{
testServer.handle((s) {
s.send("HTTP/1.1 200 OK\r\n"~
"Content-Length: 0\r\n"~
"Content-Type: text/plain; " ~ c ~ "=foo\r\n" ~
"\r\n");
});

auto http = HTTP(testServer.addr);
http.perform();
assert(http.p.charset == "foo");
}
}

/**
FTP client functionality.
Expand Down

0 comments on commit 84f7662

Please sign in to comment.