aboutsummaryrefslogtreecommitdiff
path: root/lib/http/testdata/GenerateFormData_test.txt
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2024-04-23 19:15:54 +0700
committerShulhan <ms@kilabit.info>2024-04-24 14:57:02 +0700
commit072a5866613aab933d03bef7df5a2dcb3a0855e4 (patch)
tree79f185033d4e43fde44ded7bb4e7e59d047e4941 /lib/http/testdata/GenerateFormData_test.txt
parent225b6372d0592c2291ff4b9301a68c80d4660d77 (diff)
downloadpakakeh.go-072a5866613aab933d03bef7df5a2dcb3a0855e4.tar.xz
lib/http: refactoring "multipart/form-data" parameters in ClientRequest
Previously, ClientRequest with type RequestTypeMultipartForm pass the type "map[string][]byte" in Params. This type hold the file upload, where key is the file name and []byte is content of file. Unfortunately, this model does not correct because a "multipart/form-data" can contains different field name and file name, for example --boundary Content-Disposition: form-data; name="field0"; filename="file0" Content-Type: application/octet-stream <Content of file0> This changes fix this by changing the parameter type for RequestTypeMultipartForm to [*multipart.Form], which affect several functions including [Client.PutFormData] and [GenerateFormData]. We also add new function [CreateMultipartFileHeader] to help creating [multipart.FileHeader] from raw bytes, that can be assigned to [*multipart.Form].
Diffstat (limited to 'lib/http/testdata/GenerateFormData_test.txt')
-rw-r--r--lib/http/testdata/GenerateFormData_test.txt22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/http/testdata/GenerateFormData_test.txt b/lib/http/testdata/GenerateFormData_test.txt
new file mode 100644
index 00000000..b209e07f
--- /dev/null
+++ b/lib/http/testdata/GenerateFormData_test.txt
@@ -0,0 +1,22 @@
+
+>>> file0
+Content of file0.
+
+<<< file0.ContentType
+multipart/form-data; boundary=616e646f6d73656564616e646f6d73656564616e646f6d73656564616e64
+
+<<< file0.Body
+--616e646f6d73656564616e646f6d73656564616e646f6d73656564616e64
+Content-Disposition: form-data; name="field0"; filename="file0"
+Content-Type: application/octet-stream
+
+Content of file0.
+--616e646f6d73656564616e646f6d73656564616e646f6d73656564616e64
+Content-Disposition: form-data; name="field1"
+
+value1
+--616e646f6d73656564616e646f6d73656564616e646f6d73656564616e64
+Content-Disposition: form-data; name="field1"
+
+value1.1
+--616e646f6d73656564616e646f6d73656564616e646f6d73656564616e64--