From b080ed197b1f027aa6f400840a4136d1451f9624 Mon Sep 17 00:00:00 2001 From: bptato Date: Sun, 14 May 2023 13:44:59 +0200 Subject: Name negative response codes --- src/buffer/buffer.nim | 6 ++++-- src/buffer/container.nim | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/buffer') diff --git a/src/buffer/buffer.nim b/src/buffer/buffer.nim index bb255f14..2d93214a 100644 --- a/src/buffer/buffer.nim +++ b/src/buffer/buffer.nim @@ -568,6 +568,7 @@ proc loadResources(buffer: Buffer, document: Document): EmptyPromise = return all(promises) type ConnectResult* = object + invalid*: bool code*: int needsAuth*: bool redirect*: Request @@ -577,7 +578,7 @@ type ConnectResult* = object proc setupSource(buffer: Buffer): ConnectResult = if buffer.connected: - result.code = -2 + result.invalid = true return let source = buffer.source let setct = source.contenttype.isNone @@ -586,11 +587,12 @@ proc setupSource(buffer: Buffer): ConnectResult = buffer.url = source.location case source.t of CLONE: + #TODO clone should probably just fork() the buffer instead. let s = connectSocketStream(source.clonepid, blocking = false) buffer.istream = s buffer.fd = cast[int](s.source.getFd()) if buffer.istream == nil: - result.code = -2 + result.code = ERROR_SOURCE_NOT_FOUND return if setct: buffer.contenttype = "text/plain" diff --git a/src/buffer/container.nim b/src/buffer/container.nim index 7dfd26b9..118bb57d 100644 --- a/src/buffer/container.nim +++ b/src/buffer/container.nim @@ -695,7 +695,7 @@ proc load(container: Container) = container.setLoadInfo("Connecting to " & container.location.host & "...") container.iface.connect().then(proc(res: ConnectResult): auto = let info = container.loadinfo - if res.code != -2: + if not res.invalid: container.code = res.code if res.code == 0: container.triggerEvent(SUCCESS) -- cgit 1.4.1-2-gfad0