Skip to content

Commit 956fdff

Browse files
authored
net.http: allow custom headers in post_multipart_form (#11971)
1 parent 4fbf3fd commit 956fdff

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

vlib/net/http/http.v

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,23 @@ pub fn post_form(url string, data map[string]string) ?Response {
8080
)
8181
}
8282

83+
[params]
8384
pub struct PostMultipartFormConfig {
84-
form map[string]string
85-
files map[string][]FileData
85+
pub mut:
86+
form map[string]string
87+
files map[string][]FileData
88+
header Header
8689
}
8790

8891
// post_multipart_form sends a POST HTTP request to the URL with multipart form data
8992
pub fn post_multipart_form(url string, conf PostMultipartFormConfig) ?Response {
9093
body, boundary := multipart_form_body(conf.form, conf.files)
94+
mut header := conf.header
95+
header.set(.content_type, 'multipart/form-data; boundary="$boundary"')
9196
return fetch(
9297
method: .post
9398
url: url
94-
header: new_header(key: .content_type, value: 'multipart/form-data; boundary="$boundary"')
99+
header: header
95100
data: body
96101
)
97102
}

0 commit comments

Comments
 (0)