mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
net.http: allow custom headers in post_multipart_form (#11971)
This commit is contained in:
parent
4fbf3fdf03
commit
956fdffd96
@ -80,18 +80,23 @@ pub fn post_form(url string, data map[string]string) ?Response {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[params]
|
||||||
pub struct PostMultipartFormConfig {
|
pub struct PostMultipartFormConfig {
|
||||||
|
pub mut:
|
||||||
form map[string]string
|
form map[string]string
|
||||||
files map[string][]FileData
|
files map[string][]FileData
|
||||||
|
header Header
|
||||||
}
|
}
|
||||||
|
|
||||||
// post_multipart_form sends a POST HTTP request to the URL with multipart form data
|
// post_multipart_form sends a POST HTTP request to the URL with multipart form data
|
||||||
pub fn post_multipart_form(url string, conf PostMultipartFormConfig) ?Response {
|
pub fn post_multipart_form(url string, conf PostMultipartFormConfig) ?Response {
|
||||||
body, boundary := multipart_form_body(conf.form, conf.files)
|
body, boundary := multipart_form_body(conf.form, conf.files)
|
||||||
|
mut header := conf.header
|
||||||
|
header.set(.content_type, 'multipart/form-data; boundary="$boundary"')
|
||||||
return fetch(
|
return fetch(
|
||||||
method: .post
|
method: .post
|
||||||
url: url
|
url: url
|
||||||
header: new_header(key: .content_type, value: 'multipart/form-data; boundary="$boundary"')
|
header: header
|
||||||
data: body
|
data: body
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user