full QUIC support

This commit is contained in:
Jorijn van der Graaf 2026-05-07 00:06:44 +02:00
commit 28fab2509b
18 changed files with 1334 additions and 645 deletions

View file

@ -20,19 +20,35 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
export module Crafter.Network:ClientHTTP;
import std;
import :ClientTCP;
import :HTTP;
import :ClientQUIC;
namespace Crafter {
export class ClientHTTP {
public:
std::string host;
std::uint16_t port;
ClientHTTP(const char* host, std::uint16_t port);
ClientHTTP(std::string host, std::uint16_t port);
HTTPResponse Send(const char* request, std::uint32_t length);
HTTPResponse Send(std::string request);
private:
ClientTCP client;
};
}
// HTTP/3 client over QUIC. The constructor establishes the QUIC connection
// (TLS handshake + ALPN "h3"); each Send() opens a fresh request stream
// on the multiplexed connection. Thread-affinity: Send() is not safe to
// call from multiple threads concurrently against the same ClientHTTP,
// but distinct ClientHTTP instances are independent.
//
// For local development against a self-signed listener, pass
// QUICClientCredentials{insecureNoServerValidation = true}.
export class ClientHTTP {
public:
std::string host;
std::uint16_t port;
ClientHTTP(const char* host, std::uint16_t port, QUICClientCredentials creds = {});
ClientHTTP(std::string host, std::uint16_t port, QUICClientCredentials creds = {});
~ClientHTTP();
ClientHTTP(const ClientHTTP&) = delete;
ClientHTTP(ClientHTTP&&) noexcept;
// Send a request and synchronously read back the full response.
HTTPResponse Send(const HTTPRequest& request);
private:
struct Impl;
std::unique_ptr<Impl> impl;
};
}