1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

net.http: Response.text -> Response.body (#14478)

This commit is contained in:
Hunam
2022-05-29 19:27:18 +02:00
committed by GitHub
parent 2c5febe25e
commit 78d1b7f4ef
19 changed files with 65 additions and 74 deletions

View File

@ -7,9 +7,9 @@ fn vlang_time(mut wg sync.WaitGroup) ?string {
data := http.get('https://vlang.io/utc_now')?
finish := time.ticks()
println('Finish getting time ${finish - start} ms')
println(data.text)
println(data.body)
wg.done()
return data.text
return data.body
}
fn remote_ip(mut wg sync.WaitGroup) ?string {
@ -17,9 +17,9 @@ fn remote_ip(mut wg sync.WaitGroup) ?string {
data := http.get('https://api.ipify.org')?
finish := time.ticks()
println('Finish getting ip ${finish - start} ms')
println(data.text)
println(data.body)
wg.done()
return data.text
return data.body
}
fn main() {

View File

@ -7,6 +7,6 @@ fn main() {
return
}
t := time.unix(resp.text.int())
t := time.unix(resp.body.int())
println(t.format())
}

View File

@ -46,7 +46,7 @@ fn main() {
return
}
weather := json.decode(Weather, resp.text) or {
weather := json.decode(Weather, resp.body) or {
println('failed to decode weather json')
return
}

View File

@ -11,7 +11,7 @@ fn (h ExampleHandler) handle(req Request) Response {
})
}
mut status_code := 200
res.text = match req.url {
res.body = match req.url {
'/foo' {
'bar\n'
}

View File

@ -8,7 +8,7 @@ fn send_request(mut wg sync.WaitGroup) ?string {
finish := time.ticks()
println('Finish getting time ${finish - start} ms')
wg.done()
return data.text
return data.body
}
fn main() {

View File

@ -16,7 +16,7 @@ fn worker_fetch(p &pool.PoolProcessor, cursor int, worker_id int) voidptr {
println('failed to fetch data from /v0/item/${id}.json')
return pool.no_result
}
story := json.decode(Story, resp.text) or {
story := json.decode(Story, resp.body) or {
println('failed to decode a story')
return pool.no_result
}
@ -30,7 +30,7 @@ fn main() {
println('failed to fetch data from /v0/topstories.json')
return
}
ids := json.decode([]int, resp.text) or {
ids := json.decode([]int, resp.body) or {
println('failed to decode topstories.json')
return
}#[0..10]