We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 57b1328 commit de8226dCopy full SHA for de8226d
1 file changed
vlib/net/http/http_test.v
@@ -77,3 +77,26 @@ fn test_relative_redirects() {
77
assert res.body != ''
78
assert res.body.contains('"abc": "xyz"')
79
}
80
+
81
+fn test_default_user_agent() {
82
+ $if !network ? {
83
+ return
84
+ }
85
+ res := http.get('https://httpbin.org/user-agent') or { panic(err) }
86
+ assert res.status() == .ok
87
+ assert res.body != ''
88
+ assert res.body.contains('"user-agent": "v.http"')
89
+}
90
91
+fn test_custom_user_agent() {
92
93
94
95
+ ua := 'V http test for UA'
96
+ mut req := http.new_request(.get, 'https://httpbin.org/user-agent', '')
97
+ req.user_agent = ua
98
+ res := req.do() or { panic(err) }
99
100
101
+ assert res.body.contains('"user-agent": "${ua}"')
102
0 commit comments