about summary refs log tree commit diff stats
path: root/src/loader/cgi.nim
Commit message (Collapse)AuthorAgeFilesLines
* Update code stylebptato2024-04-171-2/+2
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* fflush() before forksbptato2024-03-281-0/+2
| | | | | seems like a good idea, especially because CGI uses stdout as the IPC mechanism
* js: proper distinction between Opt/Optionbptato2024-03-241-1/+0
| | | | | | | | | | | | | | | | until now, this had very strange (and inconsistent) semantics: * err() was used for exception propagation, but also as a null value * Option accepted undefined as a none value, but not null * Opt and Option were used interchangeably (and mostly randomly) Now, Result is always used for error reporting, and err(nil) means JS_EXCEPTION. (Opt is a special case of Result where we don't care about the error type, and is not used in JS.) Option on the other hand means "nullable variation of normally non-nullable type", and translates to JS_NULL. In JS we mainly use it for turning strings nullable.
* cgi: reset SIGCHLD handler in childrenbptato2024-03-241-0/+4
| | | | this was causing problems in git.cgi
* io: derive DynStream from RootObj (not Stream)bptato2024-03-241-2/+2
| | | | | | | | This way they are no longer compatible, but we no longer need them to be compatible anyway. (This also forces us to throw out the old serialize module, and use packet writers everywhere.)
* loader: set static CGI env vars in initLoaderContextbptato2024-03-211-7/+0
| | | | no reason to do it separately in setupEnv
* main: set CHA_LIBEXEC_DIR env var at startupbptato2024-03-191-5/+4
| | | | This way, we can use it everywhere (e.g. in mailcap).
* cgi: set cwd to CGI dirbptato2024-03-191-3/+7
| | | | | for w3m and real CGI compatibility; also, it makes more sense than using whatever directory the user happened to be in when starting the browser
* cgi: fix broken pipe handlingbptato2024-03-141-1/+8
| | | | | if the socket is closed before the loader could send all header data, we must destroy the parser to avoid sending a result twice.
* Move around some modulesbptato2024-03-141-1/+1
| | | | | | | | * extern -> gone, runproc absorbed by pager, others moved into io/ * display -> local/ (where else would we display?) * xhr -> html/ * move out WindowAttributes from term, so we don't depend on local from server
* loader: fix crash on malformed CGI headersbptato2024-03-141-2/+1
| | | | | Setting istream to nil was preventing finishCycle from unregistering & closing it.
* loader: fix nil deref in parseHeadersbptato2024-03-131-1/+1
|
* loader: rework process modelbptato2024-03-111-56/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Originally we had several loader processes so that the loader did not need asynchronity for loading several buffers at once. Since then, the scope of what loader does has been reduced significantly, and with that loader has become mostly asynchronous. This patch finishes the above work as follows: * We only fork a single loader process for the browser. It is a waste of resources to do otherwise, and would have made future work on a download manager very difficult. * loader becomes (almost) fully async. Now the only sync part is a) processing commands and b) waiting for clients to consume responses. b) is a bit more problematic than a), but should not cause problems unless some other horrible bug exists in a client. (TODO: make it fully async.) This gives us a noticable improvement in CSS loading speed, since all resources can now be queried at once (even before the previous ones are connected). * Buffers now only get processes when the *connection* is finished. So headers, status code, etc. are handled by the client, and the buffer is forked when the loader starts streaming the response body. As a result, mailcap entries can simply dup2 the first UNIX domain socket connection as their stdin. This allows us to remove the ugly (and slow) `canredir' hack, which required us to send file handles on a tour accross the entire codebase. * The "cache" has been reworked somewhat: - Since canredir is gone, buffer-level requests usually start in a suspended state, and are explicitly resumed only after the client could decide whether it wants to cache the response. - Instead of a flag on Request and the URL as the cache key, we now use a global counter and the special `cache:' scheme. * misc fixes: referer_from is now actually respected by buffers (not just the pager), load info display should work slightly better, etc.
* cgi: do not eat first word of the error messagebptato2024-03-071-1/+1
| | | | whoops
* cgi: pass system error message after execl failurebptato2024-03-071-1/+2
|
* cgi: fix regression in header handlingbptato2024-03-021-5/+8
| | | | it's a good idea to use the return value, but it must substitute atEnd.
* posixstream: add readLine implementationbptato2024-03-021-6/+4
| | | | | slightly more efficient, but more importantly does not choke on NUL and weird \r\n
* cgi: do not register closed istreamsbptato2024-02-091-1/+2
|
* loader: clean up error handlingbptato2024-01-261-22/+20
| | | | | | | | | * remove pointless exception -> bool conversions; usually they were ignored anyway + exceptions are more convenient here * add EPIPE handler to raisePosixIOError * fix socketstream to use raisePosixIOError * fix socketstream sendFileHandle error handling * cgi: immediately return on file not found error
* cgi: fix broken libexec path env variablebptato2024-01-261-6/+5
|
* Add urlenc, urldec; fix a URL encoding bug; improve trans.cgibptato2024-01-081-0/+2
| | | | | | | | | | * Fix incorrect internal definition of the fragment percent-encode set * urlenc, urldec: these are simple utility programs mainly for use with shell local CGI scripts. (Sadly the printf + xargs solution is not portable.) * Pass libexec directory as an env var to local CGI scripts * Update trans.cgi to use urldec and add an example for combining it with selections
* Use std/* imports everywherebptato2024-01-071-5/+5
|
* Compile with styleCheck:usagesbptato2023-12-281-2/+2
| | | | much better
* cgi: return ConnectionError when script is not executablebptato2023-12-211-1/+2
|
* Implement local CGI error message handlingbptato2023-12-151-1/+7
| | | | | | This was documented, but not implemented until now. Also, improve the loader module's protocol documentation.
* Move http out of main binarybptato2023-12-131-17/+15
| | | | | | | | | | | | Now it is (technically) no longer mandatory to link to libcurl. Also, Chawan is at last completely protocol and network backend agnostic :) * Implement multipart requests in local CGI * Implement simultaneous download of CGI data * Add REQUEST_HEADERS env var with all headers * cssparser: add a missing check in consumeEscape
* Move out ftp: protocol; fix some local CGI bugsbptato2023-12-121-8/+15
|
* Move out file: protocol handling to adapter/bptato2023-12-121-1/+0
|
* local CGI improvements, move data: to cgi-binbptato2023-12-121-14/+82
| | | | error codes are WIP, not final yet...
* local CGI: add mapped URI env vars; move about: to adaptersbptato2023-12-121-3/+16
| | | | | | | | | | | | | | | * Add MAPPED_URI_* as environment variables when a request is coming from urimethodmap It costs us compatibility with w3m, but it seems to be a massive improvement over smuggling in the URL as a query string and then writing an ad-hoc parser for every single urimethodmap script. The variables are set for every urimethodmap request, to avoid accidental leaking of global environment variables. * Move about: to adapters (an obvious improvement over the previous solution)
* Add w3m-cgi-compat optionbptato2023-10-011-1/+5
|
* loader: add local-cgibptato2023-09-301-0/+165
Add w3m-style local CGI support. It is not quite as powerful as w3m's local CGI, because it lacks an equivalent to W3m-control. Not sure if it's worth adding; we certainly shouldn't allow passing JS in headers, but a custom language for headers does not sound like a great idea either... eh, idk. also, TODO add multipart