mirror of
https://github.com/leanprover/lean4.git
synced 2026-03-17 18:34:06 +00:00
Merge branch 'sofia/async-http-h1' into sofia/async-http-server
This commit is contained in:
@@ -162,7 +162,7 @@ instance : Writer Full where
|
||||
instance : Writer Empty where
|
||||
send _ _ _ := throw <| .userError "cannot send"
|
||||
close _ := pure ()
|
||||
isClosed _ := pure false
|
||||
isClosed _ := pure true
|
||||
hasInterest _ := pure false
|
||||
getKnownSize _ := pure (some (.fixed 0))
|
||||
setKnownSize _ _ := pure ()
|
||||
|
||||
@@ -6,7 +6,6 @@ Authors: Sofia Rodrigues
|
||||
module
|
||||
|
||||
prelude
|
||||
import Std.Tactic.BVDecide
|
||||
public import Init.Data.String
|
||||
|
||||
@[expose]
|
||||
|
||||
@@ -893,7 +893,9 @@ def canContinue (machine : Machine dir) (status : Status) : Machine dir :=
|
||||
|>.setReaderState .closed
|
||||
| .receiving, _ => machine
|
||||
|
||||
/-- Enqueues body chunks into the writer buffer for encoding and sending. -/
|
||||
/--
|
||||
Enqueues body chunks into the writer buffer for encoding and sending.
|
||||
-/
|
||||
@[inline]
|
||||
def sendData (machine : Machine dir) (data : Array Chunk) : Machine dir :=
|
||||
if data.isEmpty then
|
||||
@@ -901,12 +903,16 @@ def sendData (machine : Machine dir) (data : Array Chunk) : Machine dir :=
|
||||
else
|
||||
machine.modifyWriter (fun writer => { writer with userData := writer.userData ++ data })
|
||||
|
||||
/-- Takes and clears all accumulated events, returning the drained array. -/
|
||||
/--
|
||||
Takes and clears all accumulated events, returning the drained array.
|
||||
-/
|
||||
@[inline]
|
||||
def takeEvents (machine : Machine dir) : Machine dir × Array (Event dir) :=
|
||||
({ machine with events := #[] }, machine.events)
|
||||
|
||||
/-- Takes all accumulated output to send to the socket. -/
|
||||
/--
|
||||
Takes and clears accumulated output bytes, returning them as a buffer.
|
||||
-/
|
||||
@[inline]
|
||||
def takeOutput (machine : Machine dir) : Machine dir × ChunkedBuffer :=
|
||||
let output := machine.writer.outputData
|
||||
|
||||
@@ -489,7 +489,8 @@ def parseReasonPhrase (limits : H1.Config) : Parser String := do
|
||||
liftOption <| String.fromUTF8? bytes.toByteArray
|
||||
|
||||
/--
|
||||
Parses HTTP status code (3 digits)
|
||||
Parses a status-code (3 decimal digits), the following reason phrase, and the
|
||||
terminating CRLF; returns a typed `Status`.
|
||||
-/
|
||||
def parseStatusCode (limits : H1.Config) : Parser Status := do
|
||||
let d1 ← digit
|
||||
|
||||
@@ -71,7 +71,7 @@ inductive Writer.State
|
||||
| complete
|
||||
|
||||
/--
|
||||
State that it has completed and cannot process more data.
|
||||
Closed; no further data can be written.
|
||||
-/
|
||||
| closed
|
||||
deriving Inhabited, Repr, BEq
|
||||
|
||||
Reference in New Issue
Block a user