Skip to content

Unable to run the given client example #249

Closed
@thomas-huegel

Description

@thomas-huegel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions