From a015c44a3668a68a663a7781a1d47e210c29d7c3 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Sun, 4 Sep 2022 21:17:29 +0200 Subject: [PATCH] Improve http3 demo for easy use with Firefox --- examples/Http3Server.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/Http3Server.cpp b/examples/Http3Server.cpp index b02299f..6176f9f 100644 --- a/examples/Http3Server.cpp +++ b/examples/Http3Server.cpp @@ -26,10 +26,10 @@ int main() { .key_file_name = "misc/key.pem", .cert_file_name = "misc/cert.pem", .passphrase = "1234" - })).get("/video.mp4", [&buffer](auto *res, auto *req) { + })).get("/*", [&buffer](auto *res, auto *req) { res->writeHeader("Alt-Svc", "h3=\":9004\""); res->writeHeader("Alternative-Protocol", "quic:9004"); - res->end({"This is not HTTP3!", 18}); + res->end("

This is not HTTP3! Try refreshing (works in Firefox!)

"); }).listen(9004, [](auto *listen_socket) { if (listen_socket) { std::cout << "Bootstrapping server Listening on port " << 9004 << std::endl; @@ -41,6 +41,8 @@ int main() { .key_file_name = "misc/key.pem", .cert_file_name = "misc/cert.pem", .passphrase = "1234" + }).get("/*", [&buffer](auto *res, auto *req) { + res->end("

Welcome to HTTP3! Go see a movie

"); }).get("/video.mp4", [&buffer](auto *res, auto *req) { /* Send back a video */ res->end({&buffer[0], buffer.size()});