diff options
author | bptato <nincsnevem662@gmail.com> | 2024-09-28 17:56:45 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-09-28 17:56:45 +0200 |
commit | 1dea3e9fbe4a902db6325195df0d7a465f82cfc5 (patch) | |
tree | d400bcaa2fdf4c71a81919a45c0a58a345bbc8fc /src | |
parent | 6a0e957e1f2c9f5bea0882efbf2e0494cd5074fa (diff) | |
download | chawan-1dea3e9fbe4a902db6325195df0d7a465f82cfc5.tar.gz |
gopher: do not depend on libcurl
I'm thinking of making libcurl entirely optional; let's start with the easiest part. I've added a SOCKS5 client for ALL_PROXY support; I know curl supported others too, but whatever.
Diffstat (limited to 'src')
-rw-r--r-- | src/io/dynstream.nim | 8 | ||||
-rw-r--r-- | src/loader/connecterror.nim | 6 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/io/dynstream.nim b/src/io/dynstream.nim index e9c69c58..4a711c12 100644 --- a/src/io/dynstream.nim +++ b/src/io/dynstream.nim @@ -80,6 +80,9 @@ proc recvDataLoop*(s: DynStream; buffer: pointer; len: int) = proc recvDataLoop*(s: DynStream; buffer: var openArray[uint8]) {.inline.} = s.recvDataLoop(addr buffer[0], buffer.len) +proc recvDataLoop*(s: DynStream; buffer: var openArray[char]) {.inline.} = + s.recvDataLoop(addr buffer[0], buffer.len) + proc recvAll*(s: DynStream): string = var buffer = newString(4096) var idx = 0 @@ -161,7 +164,10 @@ method sclose*(s: PosixStream) = s.closed = true proc newPosixStream*(fd: FileHandle): PosixStream = - return PosixStream(fd: fd, blocking: true) + return PosixStream(fd: cint(fd), blocking: true) + +proc newPosixStream*(fd: SocketHandle): PosixStream = + return PosixStream(fd: cint(fd), blocking: true) proc newPosixStream*(path: string; flags, mode: cint): PosixStream = let fd = open(cstring(path), flags, mode) diff --git a/src/loader/connecterror.nim b/src/loader/connecterror.nim index 878bc8d0..1ee4e48b 100644 --- a/src/loader/connecterror.nim +++ b/src/loader/connecterror.nim @@ -25,6 +25,9 @@ type ConnectionError* = enum ceProxyRefusedToConnect = (6, "ProxyRefusedToConnect") ceFailedToResolveHost = (7, "FailedToResolveHost") ceFailedToResolveProxy = (8, "FailedToResolveProxy") + ceProxyAuthFail = (9, "ProxyAuthFail") + ceInvalidResponse = (10, "InvalidResponse") + ceProxyInvalidResponse = (11, "ProxyInvalidResponse") const ErrorMessages* = [ ceCGIOutputHandleNotFound: "request body output handle not found", @@ -53,6 +56,9 @@ const ErrorMessages* = [ ceProxyRefusedToConnect: "proxy refused to connect", ceFailedToResolveHost: "failed to resolve host", ceFailedToResolveProxy: "failed to resolve proxy", + ceProxyAuthFail: "proxy authentication failed", + ceInvalidResponse: "received an invalid response", + ceProxyInvalidResponse: "proxy returned an invalid response", ] converter toInt*(code: ConnectionError): int = |