Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
3349d20
feat: body
algebraic-dev Jan 24, 2026
18bc715
feat: remove useless functions
algebraic-dev Jan 24, 2026
3c41d39
feat: empty body and constructors
algebraic-dev Jan 25, 2026
f8ad249
test: wrong test
algebraic-dev Jan 25, 2026
53a6355
feat: H1 protocol
algebraic-dev Jan 24, 2026
12a7603
fix: orphan module
algebraic-dev Jan 25, 2026
7ce8cbc
feat: remove toString instances
algebraic-dev Jan 25, 2026
6ffd5ad
fix: incremental parsing
algebraic-dev Jan 25, 2026
3d8ba4d
Merge branch 'sofia/async-http-headers' of https://github.com/leanpro…
algebraic-dev Feb 9, 2026
f136519
fix: wireFormatSize
algebraic-dev Feb 9, 2026
294e990
feat: unify all in stream
algebraic-dev Feb 9, 2026
e7d1e7d
Merge branch 'sofia/async-http-uri' of https://github.com/leanprover/…
algebraic-dev Feb 10, 2026
aa6e11d
Merge branch 'sofia/async-http-body' of https://github.com/leanprover…
algebraic-dev Feb 10, 2026
4c64f2c
fix: suggestions
algebraic-dev Feb 10, 2026
5e3dce8
fix: chunk stream will only deal with content-size of the chunks not …
algebraic-dev Feb 10, 2026
dd125c7
Merge branch 'sofia/async-http-body' into sofia/async-http-h1
algebraic-dev Feb 10, 2026
7e215c8
Merge branch 'sofia/async-http-uri' of https://github.com/leanprover/…
algebraic-dev Feb 10, 2026
5bd2805
Merge branch 'sofia/async-http-body' of https://github.com/leanprover…
algebraic-dev Feb 10, 2026
9ad4ee3
fix: imports
algebraic-dev Feb 10, 2026
d004e17
fix: error message
algebraic-dev Feb 11, 2026
f02139f
fix: skipBytes
algebraic-dev Feb 11, 2026
2bc2080
fix: bad request behavior
algebraic-dev Feb 11, 2026
3e9674e
feat: avoid more than one host
algebraic-dev Feb 11, 2026
10c8a92
feat: readAll functions
algebraic-dev Feb 11, 2026
b12ab7e
Merge branch 'sofia/async-http-body' of https://github.com/leanprover…
algebraic-dev Feb 11, 2026
7a1f8b2
fix: readAll
algebraic-dev Feb 11, 2026
eee971e
Merge branch 'sofia/async-http-body' of https://github.com/leanprover…
algebraic-dev Feb 11, 2026
dc96616
Merge branch 'sofia/async-http-uri' of https://github.com/leanprover/…
algebraic-dev Feb 11, 2026
9485e8f
revert: add toString head
algebraic-dev Feb 11, 2026
07ed645
Merge branch 'sofia/async-http-body' of https://github.com/leanprover…
algebraic-dev Feb 11, 2026
8fe2d51
revert: chunk changes
algebraic-dev Feb 11, 2026
43aa88e
Merge branch 'sofia/async-http-body' of https://github.com/leanprover…
algebraic-dev Feb 11, 2026
058d95e
feat: maximum size in readAll
algebraic-dev Feb 12, 2026
d099586
Merge branch 'sofia/async-http-body' of https://github.com/leanprover…
algebraic-dev Feb 12, 2026
976cc79
feat: 100-continue
algebraic-dev Feb 13, 2026
07140ac
Merge branch 'sofia/async-http-uri' of https://github.com/leanprover/…
algebraic-dev Feb 13, 2026
52fdc0f
Merge branch 'sofia/async-http-uri' of https://github.com/leanprover/…
algebraic-dev Feb 13, 2026
0fd0fa9
fix: test
algebraic-dev Feb 13, 2026
1bdfdcd
Merge branch 'sofia/async-http-uri' of https://github.com/leanprover/…
algebraic-dev Feb 13, 2026
698f557
Merge branch 'sofia/async-http-uri' of https://github.com/leanprover/…
algebraic-dev Feb 13, 2026
045abb4
Merge branch 'sofia/async-http-uri' of https://github.com/leanprover/…
algebraic-dev Feb 13, 2026
a6d94c7
Merge branch 'sofia/async-http-body' of https://github.com/leanprover…
algebraic-dev Feb 13, 2026
4db36b2
feat: improve parser
algebraic-dev Feb 13, 2026
c9296c7
Merge branch 'sofia/async-http-body' of https://github.com/leanprover…
algebraic-dev Feb 13, 2026
4f20a81
fix: extension name
algebraic-dev Feb 13, 2026
4a641fc
revert: bytearray parser
algebraic-dev Feb 13, 2026
61c93a7
Merge branch 'sofia/async-http-uri' into sofia/async-http-body
algebraic-dev Feb 13, 2026
bf2ed2c
revert: h1
algebraic-dev Feb 13, 2026
9acca40
revert: h1
algebraic-dev Feb 13, 2026
9dd5f62
Merge branch 'sofia/async-http-uri' of https://github.com/leanprover/…
algebraic-dev Feb 13, 2026
96ffa3e
Merge branch 'sofia/async-http-uri' of https://github.com/leanprover/…
algebraic-dev Feb 13, 2026
8722e50
feat: pull-based body
algebraic-dev Feb 17, 2026
df738ac
fix: direction
algebraic-dev Feb 17, 2026
dd2ab67
Merge branch 'sofia/async-http-uri' into sofia/async-http-body
algebraic-dev Feb 17, 2026
ea5a986
Merge branch 'sofia/async-http-uri' into sofia/async-http-body
algebraic-dev Feb 18, 2026
6821bb8
feat: close after generate
algebraic-dev Feb 18, 2026
193bbdd
feat: incomlpete chunks
algebraic-dev Feb 18, 2026
3646590
feat: queue
algebraic-dev Feb 18, 2026
a89a69e
fix: queue test
algebraic-dev Feb 18, 2026
b8eac64
Merge branch 'sofia/async-http-uri' into sofia/async-http-body
algebraic-dev Feb 18, 2026
c423496
Merge branch 'sofia/async-http-uri' into sofia/async-http-body
algebraic-dev Feb 18, 2026
e1225ef
Merge branch 'sofia/async-http-uri' into sofia/async-http-body
algebraic-dev Feb 18, 2026
b1ff312
Merge branch 'sofia/async-http-uri' into sofia/async-http-body
algebraic-dev Feb 19, 2026
eaa1390
Merge branch 'sofia/async-http-uri' into sofia/async-http-body
algebraic-dev Feb 19, 2026
42800e4
feat: body type class
algebraic-dev Feb 20, 2026
c5db474
fix: bodyt ests
algebraic-dev Feb 20, 2026
541f9b2
fix: rendezvouz stream
algebraic-dev Feb 20, 2026
8bcc838
Merge branch 'sofia/async-http-uri' into sofia/async-http-body
algebraic-dev Feb 20, 2026
93a6ecb
feat: reader features to write only things
algebraic-dev Feb 20, 2026
549e16f
feat: add reader
algebraic-dev Feb 20, 2026
54ac93f
Merge branch 'sofia/async-http-uri' into sofia/async-http-body
algebraic-dev Feb 20, 2026
81492aa
Merge branch 'sofia/async-http-uri' into sofia/async-http-body
algebraic-dev Feb 20, 2026
999ce40
Merge branch 'sofia/async-http-uri' into sofia/async-http-body
algebraic-dev Feb 20, 2026
e62f8d6
Merge branch 'sofia/async-http-uri' into sofia/async-http-body
algebraic-dev Feb 20, 2026
bf2471b
Merge branch 'sofia/async-http-uri' into sofia/async-http-body
algebraic-dev Feb 24, 2026
74dc551
fix: test
algebraic-dev Feb 24, 2026
c266649
fix: sleep
algebraic-dev Feb 24, 2026
f68c242
Merge branch 'sofia/async-http-uri' into sofia/async-http-body
algebraic-dev Feb 26, 2026
beedfa1
fix: small comments fix and parameters
algebraic-dev Feb 26, 2026
bae251d
Merge branch 'sofia/async-http-uri' into sofia/async-http-body
algebraic-dev Feb 27, 2026
8affe05
Merge branch 'sofia/async-http-uri' into sofia/async-http-body
algebraic-dev Feb 27, 2026
aa09ab0
fix: function name
algebraic-dev Feb 27, 2026
1aa23cd
Merge branch 'sofia/async-http-uri' into sofia/async-http-body
algebraic-dev Feb 28, 2026
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
1 change: 1 addition & 0 deletions src/Std/Internal/Http/Data.lean
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public import Std.Internal.Http.Data.Status
public import Std.Internal.Http.Data.Chunk
public import Std.Internal.Http.Data.Headers
public import Std.Internal.Http.Data.URI
public import Std.Internal.Http.Data.Body

/-!
# HTTP Data Types
Expand Down
17 changes: 17 additions & 0 deletions src/Std/Internal/Http/Data/Body.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/-
Copyright (c) 2025 Lean FRO, LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sofia Rodrigues
-/
module

prelude
public import Std.Internal.Async.ContextAsync
public import Std.Internal.Http.Data.Headers
public import Std.Internal.Http.Data.Body.Basic
public import Std.Internal.Http.Data.Body.Length
public import Std.Internal.Http.Data.Body.Reader
public import Std.Internal.Http.Data.Body.Writer
public import Std.Internal.Http.Data.Body.Stream
public import Std.Internal.Http.Data.Body.Empty
public import Std.Internal.Http.Data.Body.Full
61 changes: 61 additions & 0 deletions src/Std/Internal/Http/Data/Body/Basic.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/-
Copyright (c) 2025 Lean FRO, LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sofia Rodrigues
-/
module

prelude
public import Std.Internal.Async.ContextAsync
public import Std.Internal.Http.Data.Headers
public import Std.Internal.Http.Data.Body.Length

public section

/-!
# Body.Basic

This module defines shared types for HTTP body handling.
-/

namespace Std.Http.Body

set_option linter.all true

/--
Typeclass for types that can be converted to a `ByteArray`.
-/
class ToByteArray (α : Type) where

/--
Transforms into a `ByteArray`.
-/
toByteArray : α → ByteArray

instance : ToByteArray ByteArray where
toByteArray := id

instance : ToByteArray String where
toByteArray := String.toUTF8

/--
Typeclass for types that can be decoded from a `ByteArray`. The conversion may fail with an error
message if the bytes are not valid for the target type.
-/
class FromByteArray (α : Type) where

/--
Attempts to decode a `ByteArray` into the target type, returning an error message on failure.
-/
fromByteArray : ByteArray → Except String α

instance : FromByteArray ByteArray where
fromByteArray := .ok

instance : FromByteArray String where
fromByteArray bs :=
match String.fromUTF8? bs with
| some s => .ok s
| none => .error "invalid UTF-8 encoding"

end Std.Http.Body
103 changes: 103 additions & 0 deletions src/Std/Internal/Http/Data/Body/Empty.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/-
Copyright (c) 2025 Lean FRO, LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sofia Rodrigues
-/
module

prelude
public import Std.Internal.Async
public import Std.Internal.Http.Data.Request
public import Std.Internal.Http.Data.Response
public import Std.Internal.Http.Data.Body.Length
public import Std.Internal.Http.Data.Body.Reader
public import Std.Internal.Http.Data.Chunk

public section

/-!
# Body.Empty

Represents an always-empty, already-closed body handle.
-/

namespace Std.Http.Body
open Std Internal IO Async

set_option linter.all true

/--
An empty body handle.
-/
structure Empty where
deriving Inhabited

namespace Empty

/--
Receives from an empty body, always returning end-of-stream.
-/
@[inline]
def recv (_ : Empty) : Async (Option Chunk) :=
pure none

/--
Closes an empty body (no-op).
-/
@[inline]
def close (_ : Empty) : Async Unit :=
pure ()

/--
Empty bodies are always closed for reading.
-/
@[inline]
def isClosed (_ : Empty) : Async Bool :=
pure true

open Internal.IO.Async in

/--
Selector that immediately resolves with end-of-stream for an empty body.
-/
@[inline]
def recvSelector (_ : Empty) : Selector (Option Chunk) where
tryFn := pure (some none)
registerFn waiter := do
let lose := pure ()
let win promise := do
promise.resolve (.ok none)
waiter.race lose win
unregisterFn := pure ()

end Empty

instance : Reader Empty where
recv := Empty.recv
close := Empty.close
isClosed := Empty.isClosed
recvSelector := Empty.recvSelector

end Std.Http.Body

namespace Std.Http.Request.Builder
open Internal.IO.Async

/--
Builds a request with an empty body.
-/
def blank (builder : Builder) : Async (Request Body.Empty) :=
pure <| builder.body {}

end Std.Http.Request.Builder

namespace Std.Http.Response.Builder
open Internal.IO.Async

/--
Builds a response with an empty body.
-/
def blank (builder : Builder) : Async (Response Body.Empty) :=
pure <| builder.body {}

end Std.Http.Response.Builder
Loading
Loading