Skip to content

Commit 8996984

Browse files
committed
docs: cancellation reaches the proxy hop, and where ok() stands
The README example uses the jthread's own token. CHANGELOG now names the proxies the stop reaches and the Socket and TlsSocket members that are new, and both say that ok() does not look at cancelled, as it does not look at bodyComplete.
1 parent fb5d38a commit 8996984

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ can abandon a request that is in flight.
77

88
* When the token is stopped the call returns within about 50 ms with
99
`HttpResponse::cancelled` set, and the connection is closed instead of being
10-
returned to the pool. It covers connect, the proxy CONNECT exchange, the TLS
11-
handshake, waiting for the response head, reading the body and the gaps
12-
between streaming callbacks.
10+
returned to the pool. It covers connect, the exchange with an HTTP, https or
11+
SOCKS5 proxy, the TLS handshake, waiting for the response head, reading the
12+
body and the gaps between streaming callbacks.
1313
* Before the status line arrives the response is `statusCode` 0 with
1414
`statusText` and `bodyError` `Cancelled`. After it, `statusCode` is the
1515
server's and `bodyError` is `cancelled`. A cancelled request is not retried on
16-
a new connection and its redirect is not followed.
17-
* Not covered: name resolution, and a write that is blocked because the server
18-
is not reading. Without a token nothing changes.
19-
* `proxy_connect` takes the token as a trailing default argument.
16+
a new connection and its redirect is not followed. `ok()` does not look at
17+
`cancelled`, as it does not look at `bodyComplete`.
18+
* Not covered: name resolution (`getaddrinfo`, and the lookup `socks5://` does
19+
for the target), and a write that is blocked because the server is not
20+
reading. Without a token nothing changes.
21+
* `proxy_connect` and `proxy_tunnel` take the token as a trailing default
22+
argument. `Socket` and `TlsSocket` gain `set_stop`, and `Socket` gains
23+
`stop_possible`.
2024

2125
## 0.3.3
2226

‎README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ another thread. The call returns within about 50 ms with `cancelled` set, and
5353
the connection is closed rather than pooled.
5454
5555
```cpp
56-
std::stop_source source;
57-
auto worker = std::jthread([&] { response = client.send(request, source.get_token()); });
56+
HttpResponse response;
57+
std::jthread worker([&](std::stop_token stop) { response = client.send(request, stop); });
5858
// elsewhere:
59-
source.request_stop();
59+
worker.request_stop();
6060
```
6161

6262
If the status line had not arrived, `statusCode` is 0 and `statusText` is
6363
`Cancelled`; otherwise they are the server's and `bodyError` is `cancelled`.
64-
Name resolution and a write blocked on a server that is not reading cannot be
65-
interrupted.
64+
As with `bodyComplete`, `ok()` does not look at `cancelled`. Name resolution
65+
and a write blocked on a server that is not reading cannot be interrupted.
6666

6767
### Configuration
6868

0 commit comments

Comments
 (0)