Open dasTholo opened 1 month ago
@dasTholo thanks for the detailed report! This is probably because main got updated yesterday but new package version wasn't published to the prefix channel. Just updated, you can also trying changing [dependencies]
to lightbug_http = ">=0.1.4,<0.2"
. Worked for me on a test VM, let me know if this doesn't solve the problem. Here's an example that works for me:
from lightbug_http import *
from lightbug_http.sys.client import MojoClient
fn test_request(inout client: MojoClient) raises -> None:
var uri = URI.parse_raises("http://httpbin.org/status/404")
var headers = Header("Host", "httpbin.org")
var request = HTTPRequest(uri, headers)
var response = client.do(request^)
# print status code
print("Response:", response.status_code)
# print parsed headers (only some are parsed for now)
print("Content-Type:", response.headers["Content-Type"])
print("Content-Length", response.headers["Content-Length"])
print("Server:", to_string(response.headers["Server"]))
print(
"Is connection set to connection-close? ", response.connection_close()
)
# print body
print(to_string(response.body_raw))
fn main() -> None:
try:
var client = MojoClient()
test_request(client)
except e:
print(e)
Interestingly, with your test code I'm getting URI is nil
. Will investigate this and likely address in #48
Thank you very much!
Yeah, upgrade will help with the imports! But yes "URI is nil" no result or status codes
Describe the bug I would like to test the HttpClient. But both imports will raise Errors, can you explain this import errors? I can´t understand why Headers not init.
I have install lightbug_http via magic at a new project
To Reproduce
Example 1 with import *
Errors
Example 2 with import strict imports
Errors
Desktop
[tasks]
[dependencies] max = ">=24.5.0,<25" lightbug_http = ">=0.1.3,<0.2"