Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
1a89ab0
fix break on zero read length
saviorand May 28, 2024
ec03f99
update to 2805 nightly
saviorand May 28, 2024
069a777
update unsafestring
saviorand May 28, 2024
f1077fd
Merge branch 'chore/update-nightly-2805' into feature/no-string-conve…
saviorand May 28, 2024
5399533
add header unit tests
saviorand May 30, 2024
5d8baad
fix test path
saviorand May 30, 2024
a440487
remove redundant tests
saviorand May 30, 2024
3c830c6
add empty header case
saviorand May 30, 2024
124ca5f
header response tests
saviorand May 30, 2024
384c8d7
extract split request response function
saviorand May 30, 2024
26f1d19
wip http unit tests
saviorand May 30, 2024
b394b56
wip refactor http split function
saviorand May 30, 2024
f4572df
wip uri test
saviorand May 31, 2024
aebce67
move tests to top level
saviorand May 31, 2024
e297009
add tests to workflow
saviorand May 31, 2024
2eb09f4
wip use gojo new string builder
saviorand May 31, 2024
f6f3e5f
add encode request test
saviorand May 31, 2024
bf427a7
wip refactor encode
saviorand May 31, 2024
bc433e5
return bytesview instead of bytes in header and uri
saviorand Jun 1, 2024
b5833ca
wip request encode with bytesview
saviorand Jun 1, 2024
f8d34d0
http and header tests passing
saviorand Jun 1, 2024
f287d91
tests are passing
saviorand Jun 1, 2024
88c6bf7
uncomment remaining tests
saviorand Jun 1, 2024
ae6f263
refactor header parsing
saviorand Jun 1, 2024
b1a305c
convert port to str
saviorand Jun 1, 2024
473b732
adapt to parse_raw
saviorand Jun 1, 2024
30eca36
fix protocol breaking in req
saviorand Jun 1, 2024
6a2ce19
revert to parse_from_raw
saviorand Jun 1, 2024
558174d
revert in server
saviorand Jun 1, 2024
33df73f
fix out of bounds on empty body
saviorand Jun 2, 2024
579d478
tcp keep alive parameter
saviorand Jun 2, 2024
e136899
encode response test
saviorand Jun 2, 2024
259b6a6
work around bytes pop bug
saviorand Jun 2, 2024
2fc46e1
disable pop in selected cases
saviorand Jun 2, 2024
2a6c9c7
update to latest gojo nightly
saviorand Jun 2, 2024
278f4af
update to latest nightly
saviorand Jun 6, 2024
511248b
wip fix the write issue
saviorand Jun 6, 2024
a7c8229
make up to date with release
saviorand Jun 7, 2024
d8a9b27
fix payload being truncated
saviorand Jun 7, 2024
4c494fe
remove extra prints
saviorand Jun 7, 2024
8a8b98e
wip refactoring request parsing logic
saviorand Jun 8, 2024
143d744
pointer fixes
saviorand Jun 8, 2024
936ea73
get a correct encoded request
saviorand Jun 9, 2024
73ba9a5
double the buffer size
saviorand Jun 9, 2024
557e252
use pointer directly
saviorand Jun 11, 2024
43289ee
update client
saviorand Jun 15, 2024
639cd00
update client parse_header
saviorand Jun 15, 2024
045e8ac
fix the client
saviorand Jun 15, 2024
13ec707
fix tests
saviorand Jun 16, 2024
3fd0f11
remove the printer test file
saviorand Jun 16, 2024
830334b
fix more tests
saviorand Jun 16, 2024
921e036
fix serving raw body bytes
saviorand Jun 16, 2024
06bb740
remove py client file
saviorand Jun 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions .github/workflows/package.yml → .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
name: Package and Release
name: Main pipeline

on:
push:
branches:
- main

permissions:
contents: write

jobs:
run-tests:
name: Release package
setup:
name: Setup environment and install dependencies
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install modular
run: |
curl -s https://get.modular.com | sh -
modular auth examples

- name: Install Mojo
run: modular install mojo

- name: Add to PATH
run: echo "/home/runner/.modular/pkg/packages.modular.com_mojo/bin" >> $GITHUB_PATH

- name: Create package
test:
name: Run tests
runs-on: ubuntu-latest
needs: setup
steps:
- name: Run the test suite
run: mojo run_tests.mojo
package:
name: Create package
runs-on: ubuntu-latest
needs: setup
steps:
- name: Run the package command
run: mojo package lightbug_http -o lightbug_http.mojopkg

- name: Upload package to release
uses: svenstaro/upload-release-action@v2
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.📦
.DS_Store
.mojoenv
.mojoenv
install_id
15 changes: 4 additions & 11 deletions bench.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,25 @@ import benchmark
from lightbug_http.sys.server import SysServer
from lightbug_http.python.server import PythonServer
from lightbug_http.service import TechEmpowerRouter
from lightbug_http.tests.utils import (
from tests.utils import (
TestStruct,
FakeResponder,
new_fake_listener,
FakeServer,
getRequest,
)
from external.libc import __test_socket_client__


fn main():
try:
var server = SysServer()
var server = SysServer(tcp_keep_alive=True)
var handler = TechEmpowerRouter()
server.listen_and_serve("0.0.0.0:8080", handler)
except e:
print("Error starting server: " + e.__str__())
return


fn lightbug_benchmark_get_1req_per_conn():
var req_report = benchmark.run[__test_socket_client__](1, 10000, 0, 3, 100)
print("Request: ")
req_report.print(benchmark.Unit.ns)


fn lightbug_benchmark_server():
var server_report = benchmark.run[run_fake_server](max_iters=1)
print("Server: ")
Expand All @@ -54,9 +47,9 @@ fn run_fake_server():

fn init_test_and_set_a_copy() -> None:
var test = TestStruct("a", "b")
var newtest = test.set_a_copy("c")
_ = test.set_a_copy("c")


fn init_test_and_set_a_direct() -> None:
var test = TestStruct("a", "b")
var newtest = test.set_a_direct("c")
_ = test.set_a_direct("c")
11 changes: 9 additions & 2 deletions client.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ from lightbug_http.sys.client import MojoClient

fn test_request(inout client: MojoClient) raises -> None:
var uri = URI("http://httpbin.org/status/404")
try:
uri.parse()
except e:
print("error parsing uri: " + e.__str__())


var request = HTTPRequest(uri)
var response = client.do(request)

Expand All @@ -17,11 +23,12 @@ fn test_request(inout client: MojoClient) raises -> None:
# print parsed headers (only some are parsed for now)
print("Content-Type:", String(response.header.content_type()))
print("Content-Length", response.header.content_length())
print("Connection:", response.header.connection_close())
print("Server:", String(response.header.server()))

print("Is connection set to connection-close? ", response.header.connection_close())

# print body
print(String(response.get_body()))
print(String(response.get_body_bytes()))


fn main() raises -> None:
Expand Down
1 change: 0 additions & 1 deletion external/gojo/__init__.mojo
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# gojo, created by thastoasty, https://github.com/thatstoasty/gojo/
Loading