Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
32fa066
feat: data components
algebraic-dev Jan 23, 2026
f564d43
feat: basic headers structure to more structured approach
algebraic-dev Jan 23, 2026
8544042
fix: status and chunkedbuffer
algebraic-dev Jan 25, 2026
1ef5375
fix: apply suggestions
algebraic-dev Jan 25, 2026
e47439e
fix: default size
algebraic-dev Jan 25, 2026
26dfc9a
refactor: remove headers
algebraic-dev Jan 25, 2026
5f3babe
feat: headers data structure
algebraic-dev Jan 23, 2026
d3cddf9
fix: Headers.Basic comment
algebraic-dev Jan 23, 2026
8ba86c2
fix: case and usage of native_decide
algebraic-dev Jan 23, 2026
bd28a8f
fix: tests and type class
algebraic-dev Jan 23, 2026
65883f8
fix: levenshtein test is using the new Decidable instance
algebraic-dev Jan 24, 2026
44f0868
feat: connection values
algebraic-dev Jan 24, 2026
8c34350
fix: apply suggestions
algebraic-dev Jan 25, 2026
7141144
fix: remove native_decide
algebraic-dev Jan 25, 2026
990e21e
fix: namespace
algebraic-dev Jan 25, 2026
81c67c8
revert: levenshtein test
algebraic-dev Jan 25, 2026
6e26b90
fix: encoding
algebraic-dev Jan 25, 2026
dbe0140
fix: enforce validations
algebraic-dev Feb 9, 2026
5965707
fix: apply suggestions
algebraic-dev Feb 9, 2026
3c4ae58
feat: add extensions
algebraic-dev Feb 9, 2026
a026387
fix: extensions
algebraic-dev Feb 9, 2026
e2fd8a5
Merge branch 'sofia/async-http-data' of https://github.com/leanprover…
algebraic-dev Feb 9, 2026
63984c8
fix: header value
algebraic-dev Feb 9, 2026
1cebf57
Merge branch 'master' of https://github.com/leanprover/lean4 into sof…
algebraic-dev Feb 10, 2026
f4aad3a
Merge branch 'sofia/async-http-data' of https://github.com/leanprover…
algebraic-dev Feb 10, 2026
de776c1
fix: interpolation
algebraic-dev Feb 10, 2026
b567713
Merge branch 'sofia/async-http-data' of https://github.com/leanprover…
algebraic-dev Feb 10, 2026
1cec975
fix: imports
algebraic-dev Feb 10, 2026
9332081
fix: import
algebraic-dev Feb 10, 2026
c2f657a
Merge branch 'sofia/async-http-data' of https://github.com/leanprover…
algebraic-dev Feb 10, 2026
8e5296c
fix: chunked
algebraic-dev Feb 11, 2026
3568464
Merge branch 'sofia/async-http-data' of https://github.com/leanprover…
algebraic-dev Feb 11, 2026
26d9c1c
feat: add extension handling of quotes and ExtensionName
algebraic-dev Feb 12, 2026
2956f88
refactor: move trailers
algebraic-dev Feb 12, 2026
eeff484
Merge branch 'sofia/async-http-data' of https://github.com/leanprover…
algebraic-dev Feb 12, 2026
9ce1821
feat: add trailers some type of headers
algebraic-dev Feb 12, 2026
1ae6970
fix: comment
algebraic-dev Feb 13, 2026
9430840
Merge branch 'sofia/async-http-data' of https://github.com/leanprover…
algebraic-dev Feb 13, 2026
153513d
fix: typos
algebraic-dev Feb 13, 2026
940ab9b
fix: typos
algebraic-dev Feb 13, 2026
1f2671d
merge: branch 'sofia/async-http-data'
algebraic-dev Feb 13, 2026
e0d5596
fix: typo
algebraic-dev Feb 13, 2026
87c5488
merge: 'sofia/async-http-headers'
algebraic-dev Feb 13, 2026
61d6c02
fix: typos and compareName
algebraic-dev Feb 17, 2026
6b0f05d
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Feb 17, 2026
a521ba3
fix: typos and connection token
algebraic-dev Feb 17, 2026
910c719
feat: reason phrase
algebraic-dev Feb 18, 2026
157e3b0
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Feb 18, 2026
4ba722f
fix: reasonPhrase
algebraic-dev Feb 18, 2026
3fdaf2d
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Feb 18, 2026
ad47193
fix: trailing peridos
algebraic-dev Feb 18, 2026
dd09289
fix: duplication
algebraic-dev Feb 18, 2026
78316b9
fix: isToken
algebraic-dev Feb 18, 2026
cf6b159
feat: validation in reasonPhrase
algebraic-dev Feb 19, 2026
c8c92fc
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Feb 19, 2026
b38f01e
feat: ignore reasonphrase
algebraic-dev Feb 19, 2026
96a0172
feat: reason phrase in custom status code
algebraic-dev Feb 20, 2026
0d3f6e5
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Feb 20, 2026
5a53207
feat: remove direct access
algebraic-dev Feb 20, 2026
8d8439b
fix: status code
algebraic-dev Feb 20, 2026
c457a98
fix: test
algebraic-dev Feb 20, 2026
a9ac33d
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Feb 20, 2026
f97d86c
feat: trim headers
algebraic-dev Feb 20, 2026
5626ee3
feat: specialize quote
algebraic-dev Feb 21, 2026
7902db1
fix: comments
algebraic-dev Feb 21, 2026
ab5d50c
fix: data char
algebraic-dev Feb 24, 2026
2e1bdd9
algebraic-dev Feb 24, 2026
29f651a
fix: extension values
algebraic-dev Feb 24, 2026
5914fe3
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Feb 24, 2026
36f87f9
fix: char
algebraic-dev Feb 24, 2026
9ddbb59
fix: format
algebraic-dev Feb 24, 2026
ff99979
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Feb 24, 2026
0b76c3d
fix: tests
algebraic-dev Feb 24, 2026
89c992a
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Feb 24, 2026
de7c029
feat: field content
algebraic-dev Feb 24, 2026
e65e20e
feat: field content
algebraic-dev Feb 24, 2026
8492e58
fix: comments
algebraic-dev Feb 24, 2026
a9de308
fix: RFC checks and small improvements
algebraic-dev Feb 25, 2026
3f48ef4
fix: comment
algebraic-dev Feb 25, 2026
2652ae0
fix: small changes
algebraic-dev Feb 25, 2026
e9eed5c
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Feb 25, 2026
49d00ae
fix: comments and small formatting errors
algebraic-dev Feb 26, 2026
55d357d
fix: dots
algebraic-dev Feb 26, 2026
a889085
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Feb 26, 2026
228f0d2
fix: remove unused headers
algebraic-dev Feb 26, 2026
ba36c1d
fix: comments
algebraic-dev Feb 26, 2026
cb6f540
fix: test
algebraic-dev Feb 26, 2026
91c5b71
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Feb 26, 2026
caf19b8
feat: order
algebraic-dev Feb 26, 2026
2049542
feat: order
algebraic-dev Feb 26, 2026
a0dc1db
fix: test
algebraic-dev Feb 26, 2026
b7be572
feat: forIn
algebraic-dev Feb 26, 2026
292f297
feat: small comments
algebraic-dev Feb 26, 2026
25d7db2
Merge branch 'master' of https://github.com/leanprover/lean4 into sof…
algebraic-dev Feb 27, 2026
563189f
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Feb 27, 2026
3c131da
fix: comments
algebraic-dev Feb 27, 2026
ff44193
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Feb 27, 2026
bfc6617
fix: method
algebraic-dev Feb 28, 2026
57a4d9a
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Feb 28, 2026
bf09ea8
feat: remove tests temporarily
algebraic-dev Mar 2, 2026
109ab8e
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Mar 2, 2026
29c8f8c
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Mar 2, 2026
ae30f55
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Mar 2, 2026
c7d4d8d
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Mar 3, 2026
5fb254b
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Mar 3, 2026
5a25300
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Mar 3, 2026
5a852bd
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Mar 3, 2026
d8e6b09
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Mar 3, 2026
bd4af50
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Mar 3, 2026
710eee2
refactor: head to line
algebraic-dev Mar 3, 2026
6189d4c
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Mar 3, 2026
238925a
style: change field names
algebraic-dev Mar 3, 2026
3075e50
Merge branch 'sofia/async-http-data' into sofia/async-http-headers
algebraic-dev Mar 3, 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
2 changes: 1 addition & 1 deletion src/Init/Data/String/Defs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ Examples:
* `"empty".isEmpty = false`
* `" ".isEmpty = false`
-/
@[inline] def isEmpty (s : String) : Bool :=
@[inline, expose] def isEmpty (s : String) : Bool :=
s.utf8ByteSize == 0

@[export lean_string_isempty]
Expand Down
10 changes: 10 additions & 0 deletions src/Init/Data/String/Lemmas/Modify.lean
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,14 @@ theorem length_map {f : Char → Char} {s : String} : (s.map f).length = s.lengt
theorem map_eq_empty {f : Char → Char} {s : String} : s.map f = "" ↔ s = "" := by
simp [← toList_eq_nil_iff]

@[simp]
theorem map_map {f g : Char → Char} {s : String} : String.map g (String.map f s) = String.map (g ∘ f) s := by
apply String.ext
simp [List.map_map]

@[simp]
theorem map_id {s : String} : String.map id s = s := by
apply String.ext
simp [List.map_id]

end String
2 changes: 1 addition & 1 deletion src/Init/Data/String/Modify.lean
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ Examples:
* `"Orange".toLower = "orange"`
* `"ABc123".toLower = "abc123"`
-/
@[inline] def toLower (s : String) : String :=
@[inline, expose] def toLower (s : String) : String :=
s.map Char.toLower

/--
Expand Down
1 change: 1 addition & 0 deletions src/Std/Internal/Http/Data.lean
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public import Std.Internal.Http.Data.Request
public import Std.Internal.Http.Data.Response
public import Std.Internal.Http.Data.Status
public import Std.Internal.Http.Data.Chunk
public import Std.Internal.Http.Data.Headers

/-!
# HTTP Data Types
Expand Down
115 changes: 113 additions & 2 deletions src/Std/Internal/Http/Data/Chunk.lean
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module

prelude
public import Std.Internal.Http.Internal
public import Std.Internal.Http.Data.Headers
public meta import Std.Internal.Http.Internal.String

public section
Expand All @@ -20,8 +21,7 @@ Reference: https://www.rfc-editor.org/rfc/rfc9112.html#section-7.1
-/

namespace Std.Http

open Internal
open Internal Char

set_option linter.all true

Expand Down Expand Up @@ -208,3 +208,114 @@ instance : Encode .v11 Chunk where
buffer.append #[size, exts.toUTF8, "\r\n".toUTF8, chunk.data, "\r\n".toUTF8]

end Chunk


/--
Trailer headers sent after the final chunk in HTTP/1.1 chunked transfer encoding.
Per RFC 9112 §7.1.2, trailers allow the sender to include additional metadata after
the message body, such as message integrity checks or digital signatures.
-/
structure Trailer where
/--
The trailer header fields as key-value pairs.
-/
headers : Headers
deriving Inhabited

namespace Trailer

/--
Creates an empty trailer with no headers.
-/
def empty : Trailer :=
{ headers := .empty }

/--
Inserts a trailer header field.
-/
@[inline]
def insert (trailer : Trailer) (name : Header.Name) (value : Header.Value) : Trailer :=
{ headers := trailer.headers.insert name value }

/--
Inserts a trailer header field from string name and value, panicking if either is invalid.
-/
@[inline]
def insert! (trailer : Trailer) (name : String) (value : String) : Trailer :=
{ headers := trailer.headers.insert! name value }

/--
Retrieves the first value for the given trailer header name.
Returns `none` if absent.
-/
@[inline]
def get? (trailer : Trailer) (name : Header.Name) : Option Header.Value :=
trailer.headers.get? name

/--
Retrieves all values for the given trailer header name.
Returns `none` if absent.
-/
@[inline]
def getAll? (trailer : Trailer) (name : Header.Name) : Option (Array Header.Value) :=
trailer.headers.getAll? name

/--
Checks if a trailer header with the given name exists.
-/
@[inline]
def contains (trailer : Trailer) (name : Header.Name) : Bool :=
trailer.headers.contains name

/--
Removes a trailer header with the given name.
-/
@[inline]
def erase (trailer : Trailer) (name : Header.Name) : Trailer :=
{ headers := trailer.headers.erase name }

/--
Gets the number of trailer headers.
-/
@[inline]
def size (trailer : Trailer) : Nat :=
trailer.headers.size

/--
Checks if the trailer has no headers.
-/
@[inline]
def isEmpty (trailer : Trailer) : Bool :=
trailer.headers.isEmpty

/--
Merges two trailers, accumulating values for duplicate keys from both.
-/
def merge (t1 t2 : Trailer) : Trailer :=
{ headers := t1.headers.merge t2.headers }

/--
Converts the trailer headers to a list of key-value pairs.
-/
def toList (trailer : Trailer) : List (Header.Name × Header.Value) :=
trailer.headers.toList

/--
Converts the trailer headers to an array of key-value pairs.
-/
def toArray (trailer : Trailer) : Array (Header.Name × Header.Value) :=
trailer.headers.toArray

/--
Folds over all key-value pairs in the trailer headers.
-/
def fold (trailer : Trailer) (init : α) (f : α → Header.Name → Header.Value → α) : α :=
trailer.headers.fold init f

instance : Encode .v11 Trailer where
encode buffer trailer :=
buffer.write "0\r\n".toUTF8
|> (Encode.encode .v11 · trailer.headers)
|>.write "\r\n".toUTF8

end Trailer
Loading
Loading