@@ -481,22 +481,29 @@ func MultipartAddField(writer *multipart.Writer, name string, value string) bool
481
481
return err == nil
482
482
}
483
483
484
- func MultipartAddFile (writer * multipart.Writer , name , filename , ctype , value string ) bool {
485
- // CreateFormFile doesn't expose Content-Type
484
+ func MultipartAddPart (writer * multipart.Writer , headers map [string ]string , body string ) bool {
486
485
h := make (textproto.MIMEHeader )
487
- h . Set ( "Content-Disposition" ,
488
- fmt . Sprintf ( `form-data; name="%s"; filename="%s"` , name , filename ) )
489
- h . Set ( "Content-Type" , ctype )
486
+ for k , v := range headers {
487
+ h . Set ( k , v )
488
+ }
490
489
491
490
fw , err := writer .CreatePart (h )
492
491
if err != nil {
493
492
return false
494
493
}
495
- _ , err = io .Copy (fw , strings .NewReader (value ))
494
+ _ , err = io .Copy (fw , strings .NewReader (body ))
496
495
497
496
return err == nil
498
497
}
499
498
499
+ func MultipartAddFile (writer * multipart.Writer , name , filename , ctype , value string ) bool {
500
+ // CreateFormFile doesn't expose Content-Type
501
+ return MultipartAddPart (writer , map [string ]string {
502
+ "Content-Disposition" : fmt .Sprintf (`form-data; name="%s"; filename="%s"` , name , filename ),
503
+ "Content-Type" : ctype ,
504
+ }, value )
505
+ }
506
+
500
507
// Provided an HTTP request, find the Set-Cookie headers, and extract
501
508
// the value of the specified cookie. Example:.
502
509
func GetSetCookieValue (resp * http.Response , name string ) (string , bool ) {
0 commit comments