Skip to content

Commit 40570ba

Browse files
committed
fix: comments
1 parent b3f5eb8 commit 40570ba

File tree

4 files changed

+11
-20
lines changed

4 files changed

+11
-20
lines changed

src/Std/Internal/Http/Data/Body.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ deriving Inhabited
4545

4646
namespace Body
4747

48-
instance : EmptyCollection Body where
49-
emptyCollection := Body.zero
50-
5148
/--
5249
Get content length of a body (if known).
5350
-/
@@ -75,6 +72,9 @@ instance : Coe ByteArray Body where
7572
instance : Coe Body.ByteStream Body where
7673
coe := .stream
7774

75+
instance : EmptyCollection Body where
76+
emptyCollection := Body.zero
77+
7878
instance : ForIn Async Body Chunk where
7979
forIn body acc step :=
8080
match body with

src/Std/Internal/Http/Data/Body/ByteStream.lean

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ prelude
99
public import Std.Sync
1010
public import Init.Data.Vector
1111
public import Std.Internal.Async
12-
public import Std.Internal.Async.IO
1312
public import Std.Internal.Http.Internal
1413
public import Std.Internal.Http.Data.Chunk
1514
public import Std.Internal.Http.Data.Body.Length
@@ -19,9 +18,9 @@ public section
1918
/-!
2019
# ByteStream
2120
22-
This module defines the `ByteStream` structure, which represents a channel for reading and
23-
writing sequences of bytes. It provides utilities for efficiently processing byte arrays
24-
in a streaming fashion, including support for chunk extensions.
21+
A `ByteStream` represents an asynchronous channel for streaming byte data in chunks. It provides an
22+
interface for producers and consumers to exchange byte arrays with optional chunk metadata (extensions),
23+
aking it suitable for HTTP chunked transfer encoding and other streaming scenarios.
2524
-/
2625

2726
namespace Std.Http.Body
@@ -55,16 +54,14 @@ def empty : Async ByteStream :=
5554
emptyWithCapacity
5655

5756
/--
58-
Tries to receive a chunk from the stream.
59-
Returns `some` with a chunk when data is available, or `none` when the stream is closed
60-
or no data is available.
57+
Tries to receive a chunk from the stream. Returns `some` with a chunk when data is available, or `none`
58+
hen the stream is closed or no data is available.
6159
-/
6260
def tryRecv (stream : ByteStream) : Async (Option Chunk) := do
6361
stream.channel.tryRecv
6462

6563
/--
66-
Receives (reads) a chunk from the stream.
67-
Returns `none` if the stream is closed and no data is available.
64+
Receives (reads) a chunk from the stream. Returns `none` if the stream is closed and no data is available.
6865
-/
6966
def recv (stream : ByteStream) : Async (Option Chunk) := do
7067
let task ← stream.channel.recv

src/Std/Internal/Http/Protocol/H1.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ partial def processRead (machine : Machine dir) : Machine dir :=
551551
machine
552552

553553
| .needChunkedBody ext 0 =>
554-
let (machine, result) := parseWith machine (parseLastChunkBody machine.config) (limit := some 1)
554+
let (machine, result) := parseWith machine (parseLastChunkBody machine.config) (limit := some 2)
555555

556556
match result with
557557
| some _ =>

src/Std/Internal/Http/Server/Connection.lean

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,8 @@ private def handle
240240
machine := machine.setKnownSize (size.getD .chunked)
241241
respStream := some stream
242242

243-
let (_, output) := machine.takeOutput
244-
245-
if output.size > 0 then
246-
Transport.sendAll socket output.data
247-
248243
if let some res := respStream then
249-
if ¬ (← res.isClosed) then
250-
res.close
244+
if ¬ (← res.isClosed) then res.close
251245

252246
end Connection
253247

0 commit comments

Comments
 (0)