Skip to content

Update to 25.3 #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Once you have a Mojo project set up locally,

```toml
[dependencies]
lightbug_http = ">=0.1.19"
lightbug_http = ">=25.3.0"
```

3. Run `magic install` at the root of your project, where `mojoproject.toml` is located
Expand Down
2 changes: 1 addition & 1 deletion lightbug_http/_libc.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ fn inet_ntop[address_family: AddressFamily, address_length: AddressLength](ip_ad
if result[i] == 0:
break
i += 1
dst._buffer._len = i + 1
dst._len_or_data = i + 1

# `inet_ntop` returns NULL on error.
if not result:
Expand Down
2 changes: 1 addition & 1 deletion lightbug_http/_logger.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct Logger[level: Int]:
@parameter
if event_level < LogLevel.WARN:
# Write to stderr if FATAL or ERROR
print(message, file=Self.STDERR)
print(message, file=FileDescriptor(Self.STDERR))
else:
print(message)

Expand Down
6 changes: 3 additions & 3 deletions lightbug_http/address.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ struct AddressConstants:
alias EMPTY = ""


trait Addr(Stringable, Representable, Writable, EqualityComparableCollectionElement):
alias _type: StringLiteral
trait Addr(Stringable, Representable, Writable, EqualityComparable, CollectionElement):
alias _type: String

fn __init__(out self):
...
Expand Down Expand Up @@ -70,7 +70,7 @@ trait AnAddrInfo:


@value
struct NetworkType(EqualityComparableCollectionElement):
struct NetworkType(EqualityComparable & CollectionElement):
var value: String

alias empty = NetworkType("")
Expand Down
2 changes: 1 addition & 1 deletion lightbug_http/cookie/request_cookie_jar.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct RequestCookieJar(Writable, Stringable):
var header_value = List[String]()
for cookie in self._inner.items():
header_value.append(cookie[].key + equal + cookie[].value)
return Header(HeaderKey.COOKIE, "; ".join(header_value))
return Header(HeaderKey.COOKIE, String("; ").join(header_value))

fn encode_to(mut self, mut writer: ByteWriter):
var header = self.to_header()
Expand Down
9 changes: 3 additions & 6 deletions lightbug_http/io/bytes.mojo
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from utils import StringSlice
from testing.testing import Testable
from memory.span import Span, _SpanIter, UnsafePointer
from lightbug_http.strings import BytesConstant
from lightbug_http.connection import default_buffer_size
Expand Down Expand Up @@ -66,9 +64,8 @@ struct ByteWriter(Writer):
@always_inline
fn consuming_write(mut self, owned s: String):
# kind of cursed but seems to work? pops the null terminator
_ = s._buffer.pop()
self._inner.extend(s._buffer^)
s._buffer = s._buffer_type()
_ = s.as_bytes()[:-1]
self._inner.extend(s.as_bytes())

@always_inline
fn write_byte(mut self, b: Byte):
Expand All @@ -85,7 +82,7 @@ alias OutOfBoundsError = "Tried to read past the end of the ByteReader."


@value
struct ByteView[origin: Origin](Testable):
struct ByteView[origin: Origin]:
"""Convenience wrapper around a Span of Bytes."""

var _inner: Span[Byte, origin]
Expand Down
3 changes: 1 addition & 2 deletions lightbug_http/strings.mojo
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from utils import StringSlice
from memory import Span
from lightbug_http.io.bytes import Bytes, bytes, byte

Expand Down Expand Up @@ -56,7 +55,7 @@ fn to_string(owned bytes: Bytes) -> String:
"""
if bytes[-1] != 0:
bytes.append(0)
return String(bytes^)
return bytes.__str__()


fn find_all(s: String, sub_str: String) -> List[Int]:
Expand Down
2 changes: 1 addition & 1 deletion lightbug_http/uri.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn unquote[expand_plus: Bool = False](input_str: String, disallowed_escapes: Lis

if len(str_bytes) > 0:
str_bytes.append(0x00)
var sub_str_from_bytes = String(Bytes(str_bytes))
var sub_str_from_bytes = Bytes(str_bytes).__str__()
for disallowed in disallowed_escapes:
sub_str_from_bytes = sub_str_from_bytes.replace(disallowed[], "")
sub_strings.append(sub_str_from_bytes)
Expand Down
1,081 changes: 261 additions & 820 deletions magic.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions mojoproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels = ["conda-forge", "https://conda.modular.com/max", "https://repo.prefix
description = "Simple and fast HTTP framework for Mojo!"
name = "lightbug_http"
platforms = ["osx-arm64", "linux-64", "linux-aarch64"]
version = "0.1.19"
version = "25.3.0"

[tasks]
build = { cmd = "rattler-build build --recipe recipes -c https://conda.modular.com/max -c conda-forge --skip-existing=all", env = {MODULAR_MOJO_IMPORT_PATH = "$CONDA_PREFIX/lib/mojo"} }
Expand All @@ -24,11 +24,11 @@ bench = { cmd = "magic run mojo -I . benchmark/bench.mojo" }
bench_server = { cmd = "bash scripts/bench_server.sh" }

[dependencies]
max = ">=25.2.0,<25.3.0"
max = ">=25.3.0,<25.4.0"

[feature.integration-tests.dependencies]
requests = ">=2.32.3,<3"
fastapi = ">=0.115.8,<0.116"
fastapi = ">=0.114.2,<0.115"

[environments]
default = { solve-group = "default" }
Expand Down
6 changes: 3 additions & 3 deletions recipes/recipe.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/prefix-dev/recipe-format/main/schema.json

context:
version: "0.1.19"
version: "25.3.0"

package:
name: "lightbug_http"
version: 0.1.19
version: 25.3.0

source:
- path: ../lightbug_http
Expand All @@ -18,7 +18,7 @@ build:

requirements:
run:
- max >=25.2.0
- max >=25.3.0

about:
homepage: https://github.com/saviorand/lightbug_http
Expand Down