Skip to content

Commit cb66fad

Browse files
authored
Merge pull request #399 from vulncheck-oss/multipart-helper
Add helper function for Multipart form data creation
2 parents 4885728 + a699dd4 commit cb66fad

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

protocol/httphelper.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,19 @@ func MultipartAddField(writer *multipart.Writer, name string, value string) bool
481481
return err == nil
482482
}
483483

484+
// MultipartCreateFormFields generates multipart form data out of the field names and values
485+
// provided via fieldMap and writes this to writer.
486+
// It returns a bool to indicate success or failure.
487+
func MultipartCreateFormFields(writer *multipart.Writer, fieldMap map[string]string) bool {
488+
for fieldName, value := range fieldMap {
489+
if ok := MultipartAddField(writer, fieldName, value); !ok {
490+
return false
491+
}
492+
}
493+
494+
return true
495+
}
496+
484497
func MultipartAddPart(writer *multipart.Writer, headers map[string]string, body string) bool {
485498
h := make(textproto.MIMEHeader)
486499
for k, v := range headers {

0 commit comments

Comments
 (0)