Skip to content

Commit ebfa32b

Browse files
committed
tinyhttps 0.3.4
A request in flight can be cancelled with a std::stop_token (mcpplibs/tinyhttps#23). A patch of a version consumers already name, so ^ resolution reaches it without a manifest change. The tinyhttps member moves to 0.3.4 and checks the new API without a network: a token stopped before send and download_to_file ends both with cancelled set and statusCode 0, and HttpResponse's four-initialiser brace-initialisation still compiles with the new field defaulted.
1 parent 5a558a4 commit ebfa32b

3 files changed

Lines changed: 42 additions & 2 deletions

File tree

‎pkgs/t/tinyhttps.lua‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ package = {
110110
},
111111
sha256 = "18ea1c333d72e02a5fd5c1486612838cc8fa102db8b3893958c8ea7b249c8a18",
112112
},
113+
["0.3.4"] = {
114+
url = {
115+
GLOBAL = "https://github.com/mcpplibs/tinyhttps/archive/refs/tags/0.3.4.tar.gz",
116+
CN = "https://gitcode.com/mcpp-res/tinyhttps/releases/download/0.3.4/tinyhttps-0.3.4.tar.gz",
117+
},
118+
sha256 = "26e0e496e053324e76ab7fc13f6fc6613a7e4ba498f3365575a80daf540941e9",
119+
},
113120
},
114121
macosx = {
115122
["0.2.1"] = {
@@ -210,6 +217,13 @@ package = {
210217
},
211218
sha256 = "18ea1c333d72e02a5fd5c1486612838cc8fa102db8b3893958c8ea7b249c8a18",
212219
},
220+
["0.3.4"] = {
221+
url = {
222+
GLOBAL = "https://github.com/mcpplibs/tinyhttps/archive/refs/tags/0.3.4.tar.gz",
223+
CN = "https://gitcode.com/mcpp-res/tinyhttps/releases/download/0.3.4/tinyhttps-0.3.4.tar.gz",
224+
},
225+
sha256 = "26e0e496e053324e76ab7fc13f6fc6613a7e4ba498f3365575a80daf540941e9",
226+
},
213227
},
214228
windows = {
215229
["0.2.1"] = {
@@ -310,6 +324,13 @@ package = {
310324
},
311325
sha256 = "18ea1c333d72e02a5fd5c1486612838cc8fa102db8b3893958c8ea7b249c8a18",
312326
},
327+
["0.3.4"] = {
328+
url = {
329+
GLOBAL = "https://github.com/mcpplibs/tinyhttps/archive/refs/tags/0.3.4.tar.gz",
330+
CN = "https://gitcode.com/mcpp-res/tinyhttps/releases/download/0.3.4/tinyhttps-0.3.4.tar.gz",
331+
},
332+
sha256 = "26e0e496e053324e76ab7fc13f6fc6613a7e4ba498f3365575a80daf540941e9",
333+
},
313334
},
314335
},
315336
}

‎tests/examples/tinyhttps/mcpp.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ name = "tinyhttps-tests"
1010
version = "0.1.0"
1111

1212
[dependencies]
13-
tinyhttps = "0.3.1"
13+
tinyhttps = "0.3.4"

‎tests/examples/tinyhttps/tests/api.cpp‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ int main() {
1818
// 0.3.0: adding fields to this aggregate left four-initialiser
1919
// brace-initialisation working, which is the whole compatibility claim.
2020
HttpResponse response{204, "No Content", {}, {}};
21+
22+
// 0.3.4: a stop token on all three entry points. One stopped before the
23+
// call ends it before anything is sent, so this needs no network and no
24+
// listener; the result says why without anyone matching text.
25+
std::stop_source stopped;
26+
stopped.request_stop();
27+
HttpClient client;
28+
HttpRequest get;
29+
get.url = "https://example.invalid/";
30+
const auto cancelled = client.send(get, stopped.get_token());
31+
const auto cancelledDownload = client.download_to_file(
32+
"https://example.invalid/file", "tinyhttps-unused", nullptr, nullptr,
33+
stopped.get_token());
2134
const bool ok = request.method == Method::POST
2235
&& request.url == "https://example.invalid/data"
2336
&& request.body == "{\"ok\":true}"
@@ -32,6 +45,12 @@ int main() {
3245
&& !not_a_status.has_value()
3346
&& response.bodyComplete // 0.3.0, defaults to true
3447
&& response.bodyError.empty()
35-
&& response.ok();
48+
&& response.ok()
49+
&& !response.cancelled // 0.3.4, defaults to false
50+
&& cancelled.cancelled
51+
&& cancelled.statusCode == 0
52+
&& !cancelled.ok()
53+
&& cancelledDownload.cancelled
54+
&& !cancelledDownload.ok();
3655
return ok ? 0 : 1;
3756
}

0 commit comments

Comments
 (0)