mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
net.http: add post_multipart_form function (#11511)
This commit is contained in:
@@ -80,6 +80,22 @@ pub fn post_form(url string, data map[string]string) ?Response {
|
||||
)
|
||||
}
|
||||
|
||||
pub struct PostMultipartFormConfig {
|
||||
form map[string]string
|
||||
files map[string][]FileData
|
||||
}
|
||||
|
||||
// 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 {
|
||||
body, boundary := multipart_form_body(conf.form, conf.files)
|
||||
return fetch(
|
||||
method: .post
|
||||
url: url
|
||||
header: new_header(key: .content_type, value: 'multipart/form-data; boundary="$boundary"')
|
||||
data: body
|
||||
)
|
||||
}
|
||||
|
||||
// put sends a PUT HTTP request to the URL with a string data
|
||||
pub fn put(url string, data string) ?Response {
|
||||
return fetch(
|
||||
|
||||
Reference in New Issue
Block a user