lightbug_http
lightbug_http copied to clipboard
Unable to run the given client example
Describe the bug
.magic/envs/default/lib/mojo/lightbug_http.mojopkg:0:0: error: unknown attribute code: 36
src/main.mojo:2:6: error: failed to materialize top-level module
from lightbug_http.client import Client
^
src/main.mojo:2:20: error:
from lightbug_http.client import Client
^
mojo: error: failed to parse the provided Mojo source module
To Reproduce
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)
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- Linux x64
- mojo 25.2.0
- lightbug_http 0.1.14
@thomas-huegel I was able to reproduce this, seems to do with the small_time dependency. Currently working on including small_time directly, not over magic, hopefully this solves the issue. Will post here when done
I shipped some changes in 0.1.19 , now this works on Mac, but I'm getting the following on Linux:
magic run mojo test.mojo
/workspaces/codespaces-blank/life/.magic/envs/default/lib/mojo/lightbug_http.mojopkg:0:0: error: unexpected trailing bytes after Attribute entry
/workspaces/codespaces-blank/life/test.mojo:2:6: error: failed to materialize top-level module
from lightbug_http.client import Client
^
/workspaces/codespaces-blank/life/test.mojo:2:20: error:
from lightbug_http.client import Client
^
/workspaces/codespaces-blank/life/.magic/envs/default/bin/mojo: error: failed to parse the provided Mojo source module
Will try to investigate
@thomas-huegel I think it's fixed now!
Works for me now. Here's how I tested this:
- Set up a blank Github Codespace (I think it's running Ubuntu),
- install Mojo 25.3.0
- Follow the instructions in the Lightbug README to add the latest Lightbug version (also
25.3.0, we switched to the same versioning as MAX) as a dependency - Add a
client.mojofile with the code you shared - Run
magic run mojo client.mojo
Let me know if this is fixed for you now as well. Will close for now and reopen in case you'll report the issue persists
It now works, thanks!