forked from Lightbug-HQ/lightbug_http
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.mojo
More file actions
29 lines (21 loc) · 673 Bytes
/
client.mojo
File metadata and controls
29 lines (21 loc) · 673 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from lightbug_http import *
from lightbug_http.client import Client
fn test_request(mut client: Client) raises -> None:
var uri = URI.parse("google.com")
var headers = Headers(Header("Host", "google.com"))
var request = HTTPRequest(uri, headers)
var response = client.do(request^)
# print status code
print("Response:", response.status_code)
print(response.headers)
print(
"Is connection set to connection-close? ", response.connection_close()
)
# print body
print(to_string(response.body_raw))
fn main() -> None:
try:
var client = Client()
test_request(client)
except e:
print(e)