about summary refs log tree commit diff stats
path: root/doc
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-11 19:15:24 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-11 21:09:52 +0100
commitb789b0b076ef7aba3f5f6bbb4f6b7cadf596994c (patch)
tree388a265fd778cd8fc3e9fad9d734628aca0bd287 /doc
parent8bf82ddbfb84b5ca32824a466380dae4df4ff31a (diff)
downloadchawan-b789b0b076ef7aba3f5f6bbb4f6b7cadf596994c.tar.gz
loader: rework process model
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.
Diffstat (limited to 'doc')
-rw-r--r--doc/config.md2
-rw-r--r--doc/mailcap.md6
-rw-r--r--doc/protocols.md18
3 files changed, 17 insertions, 9 deletions
diff --git a/doc/config.md b/doc/config.md
index d4a4f46a..854c4848 100644
--- a/doc/config.md
+++ b/doc/config.md
@@ -1186,7 +1186,7 @@ Returns `undefined`. (It should return a promise; TODO.)</td>
 </tr>
 
 <tr>
-<td>`pager.location`</td>
+<td>`pager.url`</td>
 <td>Getter for the link of the current buffer. Returns a `URL` object.</td>
 </tr>
 
diff --git a/doc/mailcap.md b/doc/mailcap.md
index de8abeaf..9c30b50f 100644
--- a/doc/mailcap.md
+++ b/doc/mailcap.md
@@ -57,7 +57,8 @@ extension fields are recognized too.
 
 * When the `test` named field is specified, the mailcap entry is only used
   if the test command returns 0.  
-  Warning: as of now, %s does not work with test.
+  Warning: as of now, `%s` does not work with `test`; `test` named fields with a
+  `%s` template are skipped. Additionally, no data is piped into `test` either.
 * `copiousoutput` makes Chawan redirect the output of the external command
   into a new buffer. If either x-htmloutput or x-ansioutput is defined too, then
   it is ignored.
@@ -69,7 +70,8 @@ extension fields are recognized too.
 * `needsterminal` hands over control of the terminal to the command while
   it is running. Note: as of now, `needsterminal` does nothing if either
   `copiousoutput` or `x-htmloutput` is specified.
-* For a description of `nametemplate`, see the RFC.
+* For a description of `nametemplate`, see the RFC. Note however, that it does
+  not work with test (since %s is not supported there).
 
 ### Environment variables
 
diff --git a/doc/protocols.md b/doc/protocols.md
index 752d5507..2f1c7afd 100644
--- a/doc/protocols.md
+++ b/doc/protocols.md
@@ -19,7 +19,7 @@ this document.
 * [Finger](#finger)
 * [Spartan](#spartan)
 * [Local schemes: file:, about:, man:, data:](#local-schemes-file-about-man-data)
-* [Internal schemes: cgi-bin:, stream:](#internal-schemes-cgi-bin-stream)
+* [Internal schemes: cgi-bin:, stream:, cache:](#internal-schemes-cgi-bin-stream-cache)
 * [Custom protocols](#custom-protocols)
 
 <!-- MANON -->
@@ -130,12 +130,12 @@ to work.
 
 `data:` decodes a data URL as defined in RFC 2397.
 
-## Internal schemes: cgi-bin:, stream:
+## Internal schemes: cgi-bin:, stream:, cache:
 
-Two internal protocols exist: `cgi-bin:` and `stream:`. These are the basic
-building blocks for the implementation of every protocol mentioned above; for
-this reason, these can *not* be replaced, and are implemented in the main
-browser binary.
+Three internal protocols exist: `cgi-bin:`, `stream:` and `cache:`. These are
+the basic building blocks for the implementation of every protocol mentioned
+above; for this reason, these can *not* be replaced, and are implemented in
+the main browser binary.
 
 `cgi-bin:` executes a local CGI script. This scheme is used for the actual
 implementation of the non-internal protocols mentioned above. Local CGI scripts
@@ -153,6 +153,12 @@ possible to reload them. (For that matter, reloading stdin does not make much
 sense anyway.) To support rewinding and "view source", the output of `stream:`'s
 is stored in a temporary file until the buffer is discarded.
 
+`cache:` is not something an end user would normally see; it's used for
+rewinding or re-interpreting streams already downloaded. Note that this is not a
+real cache; files are deterministically loaded from the "cache" upon certain
+actions, and from the network upon others, but neither is used as a fallback
+to the other.
+
 ## Custom protocols
 
 Chawan is protocol-agnostic. This means that the `cha` binary itself does not