45 lines
1.7 KiB
C++
45 lines
1.7 KiB
C++
//SPDX-License-Identifier: LGPL-3.0-only
|
|
//SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
|
|
|
import Crafter.Network;
|
|
import Crafter.Thread;
|
|
import std;
|
|
using namespace Crafter;
|
|
|
|
// External-interop smoke test: connect to a public h3 endpoint, fetch /, and
|
|
// verify a 200 response with a non-empty body. Exercises:
|
|
// - real TLS chain validation against the system trust store
|
|
// - mandatory client control stream + SETTINGS prelude
|
|
// - peer's control + QPACK encoder/decoder unidi streams (drained)
|
|
// - QPACK Huffman decode on the response headers
|
|
//
|
|
// Targets cloudflare-quic.com (Cloudflare's public h3 demo). Network-
|
|
// dependent — if outbound UDP/443 is firewalled or the endpoint goes away,
|
|
// this will fail.
|
|
int main() {
|
|
ThreadPool::Start();
|
|
try {
|
|
QUICClientCredentials creds; // default: validate against system trust
|
|
ClientHTTP client("cloudflare-quic.com", 443, creds);
|
|
HTTPResponse r = client.Send(
|
|
CreateRequestHTTP("GET", "/", "cloudflare-quic.com")
|
|
);
|
|
std::cout << "status=" << r.status << " bodyBytes=" << r.body.size() << std::endl;
|
|
if (r.headers.count("server")) {
|
|
std::cout << "server=" << r.headers["server"] << std::endl;
|
|
}
|
|
if (r.body.size() > 0) {
|
|
auto preview = r.body.substr(0, std::min<std::size_t>(80, r.body.size()));
|
|
std::cout << "preview: " << preview << std::endl;
|
|
}
|
|
if (r.status != "200" || r.body.empty()) {
|
|
std::cout << "unexpected response" << std::endl;
|
|
return 1;
|
|
}
|
|
std::cout.flush();
|
|
std::_Exit(0);
|
|
} catch (std::exception& e) {
|
|
std::println("error: {}", e.what());
|
|
return 1;
|
|
}
|
|
}
|