Add RFC5987 support for HTTP header field params

This commit adds support for HTTP header field parameters encoding, as
described in RFC5987.
Note that the default implementation still relies on US-ASCII encoding,
as the latest rfc7230 Section 3.2.4 says that:

> Newly defined header fields SHOULD limit their field values to
  US-ASCII octets

Issue: SPR-14547
Cherry-picked from: f2faf84f31
This commit is contained in:
Brian Clozel
2016-08-25 14:39:07 +02:00
parent 026473280b
commit 9b91b9db8c
4 changed files with 86 additions and 3 deletions

View File

@@ -320,6 +320,11 @@ public class HttpHeadersTests {
headers.setContentDispositionFormData("name", "filename");
assertEquals("Invalid Content-Disposition header", "form-data; name=\"name\"; filename=\"filename\"",
headers.getFirst("Content-Disposition"));
headers.setContentDispositionFormData("name", "中文.txt", Charset.forName("UTF-8"));
assertEquals("Invalid Content-Disposition header",
"form-data; name=\"name\"; filename*=UTF-8''%E4%B8%AD%E6%96%87.txt",
headers.getFirst("Content-Disposition"));
}
@Test // SPR-11917