From daca82d7aa0d3b3685450565da3cc4ae9c21b77c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Thu, 13 Aug 2015 21:08:23 +0200 Subject: [PATCH] Add test for #1220. See also #1221. --- source/vibe/inet/webform.d | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/source/vibe/inet/webform.d b/source/vibe/inet/webform.d index 268f505eaa..06ce2e7273 100644 --- a/source/vibe/inet/webform.d +++ b/source/vibe/inet/webform.d @@ -170,6 +170,34 @@ unittest assert(files["files"].filename == "file1.txt"); } +unittest +{ + import vibe.stream.memory; + + auto content_type = "multipart/form-data; boundary=\"AaB03x\""; + + auto input = new MemoryStream(cast(ubyte[]) + "--AaB03x\r\n" + "Content-Disposition: form-data; name=\"submit-name\"\r\n" + "Content-Length: 5" + "\r\n" + "Larry\r\n" + "--AaB03x\r\n" + "Content-Disposition: form-data; name=\"files\"; filename=\"file1.txt\"\r\n" + "Content-Type: text/plain\r\n" + "\r\n" + "... contents of file1.txt ...\r\n" + "--AaB03x--\r\n".dup, false); + + FormFields fields; + FilePartFormFields files; + + parseMultiPartForm(fields, files, content_type, input, 4096); + + assert(fields["submit-name"] == "Larry"); + assert(files["files"].filename == "file1.txt"); +} + /** Single part of a multipart form.