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

http: refactor and reduce duplication

This commit is contained in:
Chris Watson
2020-01-16 10:16:11 -07:00
committed by Alexander Medvednikov
parent 756c6d2858
commit 84a6c019e8
8 changed files with 274 additions and 88 deletions

View File

@@ -1,22 +1,13 @@
// import net.urllib
import net.http
fn test_escape_unescape() {
/*
original := 'те ст: т\\%'
escaped := urllib.query_escape(original) or { assert false return}
assert escaped == '%D1%82%D0%B5%20%D1%81%D1%82%3A%20%D1%82%5C%25'
unescaped := urllib.query_unescape(escaped) or { assert false return }
assert unescaped == original
*/
}
fn test_http_get() {
// $if !network ? { return }
assert http.get_text('https://vlang.io/version') == '0.1.5'
println('http ok')
}
fn test_http_get_from_vlang_utc_now() {
fn test_http_get_from_vlang_utc_now() {
// $if !network ? { return }
urls := ['http://vlang.io/utc_now', 'https://vlang.io/utc_now']
for url in urls {
println('Test getting current time from $url by http.get')
@@ -29,6 +20,7 @@ fn test_http_get_from_vlang_utc_now() {
}
fn test_public_servers() {
// $if !network ? { return }
urls := [
'http://github.com/robots.txt',
'http://google.com/robots.txt',