/* Crafter® Build Copyright (C) 2026 Catcrafts® Catcrafts.net This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3.0 as published by the Free Software Foundation; This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ 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(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; } }