mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
http: public functions
This commit is contained in:
parent
fa51b24a60
commit
fc628f2ee9
12
http/http.v
12
http/http.v
@ -28,7 +28,7 @@ pub:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// embed 'http'
|
// embed 'http'
|
||||||
fn get(url string) string {
|
pub fn get(url string) string {
|
||||||
if url == '' {
|
if url == '' {
|
||||||
println('http: empty get url')
|
println('http: empty get url')
|
||||||
return ''
|
return ''
|
||||||
@ -38,17 +38,13 @@ fn get(url string) string {
|
|||||||
return resp.body
|
return resp.body
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get2(url string) string {
|
pub fn post(url, data string) string {
|
||||||
return ''
|
|
||||||
}
|
|
||||||
|
|
||||||
fn post(url, data string) string {
|
|
||||||
req := new_request('POST', url, data)
|
req := new_request('POST', url, data)
|
||||||
resp := req.do()
|
resp := req.do()
|
||||||
return resp.body
|
return resp.body
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_request(typ, _url, _data string) *Request {
|
pub fn new_request(typ, _url, _data string) *Request {
|
||||||
mut url := _url
|
mut url := _url
|
||||||
mut data := _data
|
mut data := _data
|
||||||
// req.headers['User-Agent'] = 'V $VERSION'
|
// req.headers['User-Agent'] = 'V $VERSION'
|
||||||
@ -82,7 +78,7 @@ fn (resp mut Response) free() {
|
|||||||
resp.headers.free()
|
resp.headers.free()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (req mut Request) add_header(key, val string) {
|
pub fn (req mut Request) add_header(key, val string) {
|
||||||
// println('start add header')
|
// println('start add header')
|
||||||
// println('add header "$key" "$val"')
|
// println('add header "$key" "$val"')
|
||||||
// println(key)
|
// println(key)
|
||||||
|
Loading…
Reference in New Issue
Block a user