net.http: vfmt and remove unused ws_func
parent
329a6c974e
commit
aea93c3a96
|
@ -47,7 +47,7 @@ pub fn get(url string) ?Response {
|
||||||
pub fn post(url string, data string) ?Response {
|
pub fn post(url string, data string) ?Response {
|
||||||
return fetch_with_method(.post, url,
|
return fetch_with_method(.post, url,
|
||||||
data: data
|
data: data
|
||||||
header: new_header({key: .content_type, value: http.content_type_default})
|
header: new_header(key: .content_type, value: http.content_type_default)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,14 +55,14 @@ pub fn post(url string, data string) ?Response {
|
||||||
pub fn post_json(url string, data string) ?Response {
|
pub fn post_json(url string, data string) ?Response {
|
||||||
return fetch_with_method(.post, url,
|
return fetch_with_method(.post, url,
|
||||||
data: data
|
data: data
|
||||||
header: new_header({key: .content_type, value: 'application/json'})
|
header: new_header(key: .content_type, value: 'application/json')
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// post_form sends a POST HTTP request to the URL with X-WWW-FORM-URLENCODED data
|
// post_form sends a POST HTTP request to the URL with X-WWW-FORM-URLENCODED data
|
||||||
pub fn post_form(url string, data map[string]string) ?Response {
|
pub fn post_form(url string, data map[string]string) ?Response {
|
||||||
return fetch_with_method(.post, url,
|
return fetch_with_method(.post, url,
|
||||||
header: new_header({key: .content_type, value: 'application/x-www-form-urlencoded'})
|
header: new_header(key: .content_type, value: 'application/x-www-form-urlencoded')
|
||||||
data: url_encode_form_data(data)
|
data: url_encode_form_data(data)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ pub fn post_form(url string, data map[string]string) ?Response {
|
||||||
pub fn put(url string, data string) ?Response {
|
pub fn put(url string, data string) ?Response {
|
||||||
return fetch_with_method(.put, url,
|
return fetch_with_method(.put, url,
|
||||||
data: data
|
data: data
|
||||||
header: new_header({key: .content_type, value: http.content_type_default})
|
header: new_header(key: .content_type, value: http.content_type_default)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ pub fn put(url string, data string) ?Response {
|
||||||
pub fn patch(url string, data string) ?Response {
|
pub fn patch(url string, data string) ?Response {
|
||||||
return fetch_with_method(.patch, url,
|
return fetch_with_method(.patch, url,
|
||||||
data: data
|
data: data
|
||||||
header: new_header({key: .content_type, value: http.content_type_default})
|
header: new_header(key: .content_type, value: http.content_type_default)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,6 @@ pub fn fetch(_url string, config FetchConfig) ?Response {
|
||||||
header: config.header
|
header: config.header
|
||||||
cookies: config.cookies
|
cookies: config.cookies
|
||||||
user_agent: config.user_agent
|
user_agent: config.user_agent
|
||||||
ws_func: 0
|
|
||||||
user_ptr: 0
|
user_ptr: 0
|
||||||
verbose: config.verbose
|
verbose: config.verbose
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ pub mut:
|
||||||
user_agent string = 'v.http'
|
user_agent string = 'v.http'
|
||||||
verbose bool
|
verbose bool
|
||||||
user_ptr voidptr
|
user_ptr voidptr
|
||||||
ws_func voidptr
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut req Request) free() {
|
fn (mut req Request) free() {
|
||||||
|
@ -47,8 +46,8 @@ pub fn (req &Request) do() ?Response {
|
||||||
mut resp := Response{}
|
mut resp := Response{}
|
||||||
mut no_redirects := 0
|
mut no_redirects := 0
|
||||||
for {
|
for {
|
||||||
if no_redirects == http.max_redirects {
|
if no_redirects == max_redirects {
|
||||||
return error('http.request.do: maximum number of redirects reached ($http.max_redirects)')
|
return error('http.request.do: maximum number of redirects reached ($max_redirects)')
|
||||||
}
|
}
|
||||||
qresp := req.method_and_url_to_response(req.method, rurl) ?
|
qresp := req.method_and_url_to_response(req.method, rurl) ?
|
||||||
resp = qresp
|
resp = qresp
|
||||||
|
@ -256,7 +255,6 @@ struct MultiplePathAttributesError {
|
||||||
code int
|
code int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn parse_multipart_form(body string, boundary string) (map[string]string, map[string][]FileData) {
|
fn parse_multipart_form(body string, boundary string) (map[string]string, map[string][]FileData) {
|
||||||
sections := body.split(boundary)
|
sections := body.split(boundary)
|
||||||
fields := sections[1..sections.len - 1]
|
fields := sections[1..sections.len - 1]
|
||||||
|
|
Loading…
Reference in New Issue