|
|
@@ -20444,6 +20444,50 @@ TEST(MultipartFormDataTest, AlternateFilenameLongValueAndCaseInsensitive) {
|
|
|
ASSERT_TRUE(send_request(1, req));
|
|
|
}
|
|
|
|
|
|
+TEST(MultipartFormDataTest, AlternateFilenameWithLanguageTag) {
|
|
|
+ auto handled = false;
|
|
|
+
|
|
|
+ Server svr;
|
|
|
+ svr.Post("/test", [&](const Request &req, Response &res) {
|
|
|
+ ASSERT_EQ("A.txt", req.form.get_file("file1").filename);
|
|
|
+ ASSERT_EQ("na\xC3\xAFve.txt", req.form.get_file("file2").filename);
|
|
|
+
|
|
|
+ res.set_content("ok", "text/plain");
|
|
|
+ handled = true;
|
|
|
+ });
|
|
|
+
|
|
|
+ thread t = thread([&] { svr.listen(HOST, PORT); });
|
|
|
+ auto se = detail::scope_exit([&] {
|
|
|
+ svr.stop();
|
|
|
+ t.join();
|
|
|
+ ASSERT_FALSE(svr.is_running());
|
|
|
+ ASSERT_TRUE(handled);
|
|
|
+ });
|
|
|
+
|
|
|
+ svr.wait_until_ready();
|
|
|
+
|
|
|
+ std::string body = "----------\r\n"
|
|
|
+ "Content-Disposition: form-data; name=\"file1\"; "
|
|
|
+ "filename*=UTF-8'en'%41.txt\r\n"
|
|
|
+ "\r\n"
|
|
|
+ "hello\r\n"
|
|
|
+ "----------\r\n"
|
|
|
+ "Content-Disposition: form-data; name=\"file2\"; "
|
|
|
+ "filename*=utf-8'fr-CA'na%C3%AFve.txt\r\n"
|
|
|
+ "\r\n"
|
|
|
+ "bonjour\r\n"
|
|
|
+ "------------\r\n";
|
|
|
+
|
|
|
+ auto req = "POST /test HTTP/1.1\r\n"
|
|
|
+ "Host: localhost\r\n"
|
|
|
+ "Connection: close\r\n"
|
|
|
+ "Content-Type: multipart/form-data;boundary=--------\r\n"
|
|
|
+ "Content-Length: " +
|
|
|
+ std::to_string(body.size()) + "\r\n\r\n" + body;
|
|
|
+
|
|
|
+ ASSERT_TRUE(send_request(1, req));
|
|
|
+}
|
|
|
+
|
|
|
TEST(MultipartFormDataTest, CloseDelimiterWithoutCRLF) {
|
|
|
auto handled = false;
|
|
|
|