@@ -30,17 +30,18 @@ This is not production ready yet. We're aiming to keep up with new developments
3030
3131Lightbug currently has the following features:
3232 - [x] Pure Mojo networking! No dependencies on Python by default
33- - [x] Set up a server to listen on a given host/port
33+ - [x] TCP-based server and client implementation
3434 - [x] Assign your own custom handler to a route
3535 - [x] Craft HTTP requests and responses with built-in primitives
3636 - [x] Everything is fully typed, with no ` def ` functions used
3737
3838
3939We're working on support for the following (contributors welcome!):
4040 - [ ] [ SSL/HTTPS support] ( https://github.com/saviorand/lightbug_http/issues/20 )
41+ - [ ] UDP support
4142 - [ ] [ Better error handling] ( https://github.com/saviorand/lightbug_http/issues/3 ) , [ improved form/multipart and JSON support] ( https://github.com/saviorand/lightbug_http/issues/4 )
4243 - [ ] [ Multiple simultaneous connections] ( https://github.com/saviorand/lightbug_http/issues/5 ) , [ parallelization and performance optimizations] ( https://github.com/saviorand/lightbug_http/issues/6 )
43- - [ ] [ WebSockets] ( https://github.com/saviorand/lightbug_http/issues/7 ) , [ HTTP 2.0 support] ( https://github.com/saviorand/lightbug_http/issues/8 )
44+ - [ ] [ WebSockets] ( https://github.com/saviorand/lightbug_http/issues/7 ) , [ HTTP 2.0/3.0 support] ( https://github.com/saviorand/lightbug_http/issues/8 )
4445 - [ ] [ ASGI spec conformance] ( https://github.com/saviorand/lightbug_http/issues/17 )
4546
4647The test coverage is also something we're working on.
@@ -63,11 +64,11 @@ Once you have Mojo set up locally,
6364 git clone https://github.com/saviorand/lightbug_http.git
6465 ```
65662 . Switch to the project directory:
66- ``` bash
67+ ``` sh
6768 cd lightbug_http
6869 ```
6970 then run:
70- ``` bash
71+ ``` sh
7172 mojo lightbug.🔥
7273 ```
7374
@@ -126,6 +127,37 @@ Once you have Mojo set up locally,
126127
127128<p align =" right " >(<a href =" #readme-top " >back to top</a >)</p >
128129
130+ ### Using the client
131+
132+ Create a file, e.g ` client.mojo ` with the following code:
133+
134+ ``` mojo
135+ from lightbug_http.http import HTTPRequest
136+ from lightbug_http.uri import URI
137+ from lightbug_http.sys.client import MojoClient
138+
139+ fn test_request(inout client: MojoClient) raises -> None:
140+ var uri = URI("http://httpbin.org/")
141+ var request = HTTPRequest(uri)
142+ var response = client.do(request)
143+
144+ # print status code
145+ print("Response:", response.header.status_code())
146+
147+ # print various parsed headers
148+ print("Header", response.header.content_length())
149+
150+ # print body
151+ print(String(response.get_body()))
152+
153+
154+ fn main() raises -> None:
155+ var client = MojoClient()
156+ test_request(client)
157+ ```
158+
159+ Pure Mojo-based client is available by default. This client is also used internally for testing the server.
160+
129161## Switching between pure Mojo and Python implementations
130162By default, Lightbug uses the pure Mojo implementation for networking. To use Python's ` socket ` library instead, just import the ` PythonServer ` instead of the ` SysServer ` with the following line:
131163``` mojo
0 commit comments