diff options
author | bptato <nincsnevem662@gmail.com> | 2023-08-13 17:42:34 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-08-13 17:54:05 +0200 |
commit | d526deb99e44f2a8d1a9c3eea60676703dd64302 (patch) | |
tree | f63689ff7654d14ad9bca182a837b3155b2471a0 /src/ips/forkserver.nim | |
parent | f92e30232252deb194596e7c298cc7fcf56517cb (diff) | |
download | chawan-d526deb99e44f2a8d1a9c3eea60676703dd64302.tar.gz |
Add mailcap, mime.types & misc refactorings
* add mailcap: works with copiousoutput, needsterminal, etc. * add mime.types (only works with mailcap) * refactor pipeBuffer * remove "dispatcher" * fix bug in directory display where baseurl would not be used
Diffstat (limited to 'src/ips/forkserver.nim')
-rw-r--r-- | src/ips/forkserver.nim | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/ips/forkserver.nim b/src/ips/forkserver.nim index 62d41198..ec0c60d1 100644 --- a/src/ips/forkserver.nim +++ b/src/ips/forkserver.nim @@ -1,5 +1,6 @@ import options import streams +import tables when defined(posix): import posix @@ -36,7 +37,6 @@ type proc newFileLoader*(forkserver: ForkServer, defaultHeaders: Headers = nil, filter = newURLFilter(default = true), cookiejar: CookieJar = nil, proxy: URL = nil, acceptProxy = false): FileLoader = - new(result) forkserver.ostream.swrite(FORK_LOADER) var defaultHeaders = defaultHeaders if defaultHeaders == nil: @@ -51,7 +51,9 @@ proc newFileLoader*(forkserver: ForkServer, defaultHeaders: Headers = nil, ) forkserver.ostream.swrite(config) forkserver.ostream.flush() - forkserver.istream.sread(result.process) + var process: Pid + forkserver.istream.sread(process) + return FileLoader(process: process) proc loadForkServerConfig*(forkserver: ForkServer, config: Config) = forkserver.ostream.swrite(LOAD_CONFIG) @@ -117,7 +119,8 @@ proc forkBuffer(ctx: var ForkServerContext): Pid = filter: config.filter, cookiejar: config.cookiejar, referrerpolicy: config.referrerpolicy, - proxy: config.proxy + #TODO these should be in a separate config I think + proxy: config.proxy, ) ) let pid = fork() @@ -190,7 +193,6 @@ proc runForkServer() = quit(0) proc newForkServer*(): ForkServer = - new(result) var pipefd_in: array[2, cint] # stdin in forkserver var pipefd_out: array[2, cint] # stdout in forkserver var pipefd_err: array[2, cint] # stderr in forkserver @@ -230,7 +232,9 @@ proc newForkServer*(): ForkServer = raise newException(Defect, "Failed to open output handle") if not open(readf, pipefd_out[0], fmRead): raise newException(Defect, "Failed to open input handle") - result.ostream = newFileStream(writef) - result.istream = newFileStream(readf) - result.estream = newPosixStream(pipefd_err[0]) discard fcntl(pipefd_err[0], F_SETFL, fcntl(pipefd_err[0], F_GETFL, 0) or O_NONBLOCK) + return ForkServer( + ostream: newFileStream(writef), + istream: newFileStream(readf), + estream: newPosixStream(pipefd_err[0]) + ) |