Skip to content

Commit 25e4d50

Browse files
committed
fix: behavior of the client
1 parent cdc1cdd commit 25e4d50

File tree

4 files changed

+150
-192
lines changed

4 files changed

+150
-192
lines changed

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,7 @@ private def handle [Transport α] (connection : Connection α) (config : Client.
194194
running := false
195195
continue
196196

197-
machine := machine
198-
|> Protocol.H1.Machine.Client.processRead
199-
|> Protocol.H1.Machine.Client.processWrite
197+
machine := machine.processRead.processWrite
200198

201199
let (newMachine, events) := machine.takeEvents
202200
machine := newMachine
@@ -293,6 +291,16 @@ private def handle [Transport α] (connection : Connection α) (config : Client.
293291
connectionTimer.stop
294292
requestTimer.stop
295293

294+
requestChannel.close
295+
296+
while true do
297+
if let some x ← requestChannel.tryRecv then
298+
x.onError (.userError "connection closed, cannot send more requests")
299+
else
300+
break
301+
302+
303+
296304
end Connection
297305

298306
/--
@@ -324,6 +332,11 @@ def createPersistentConnection [Transport t] (client : t) (config : Client.Confi
324332
let connection := Connection.mk client { config := config.toH1Config }
325333
let shutdown ← IO.Promise.new
326334

327-
pure { connection, requestChannel, shutdown }
335+
let conn := { connection, requestChannel, shutdown }
336+
337+
background (Connection.handle connection config requestChannel)
338+
339+
return conn
340+
328341

329342
end Std.Http.Client

0 commit comments

Comments
 (0)